In such a situation, sometimes, developers encounter unmerged conflict because of multiple changes simultaneously and not merged. They can resolve this conflict without committing.
This guide will discuss the easiest solution to the Git stash conflict without commit.
How to Resolve Git Stash Conflict Without Commit?
Most of the time, Git stash unmerged conflicts encountered by developers when they are working on a similar project file and adding changes multiple times. To resolve this particular conflict, developers need to stage the modifications to the tracking index by executing the βgit add <filename>β command without committing.
Letβs move forward, check out when the conflict occurs, and resolve it.
Step 1: Switch to Git Repository
Execute the βcdβ command and navigate to the desired Git local directory:
Step 2: Generate and Update File
Then, generate and update a new file by running the βechoβ command:
Step 3: Track File
Next, track a newly created file into the index through the following command:
Step 4: Push Changes to Git Repository
After that, run the provided command and push changes to the Git repository:
Step 5: Update File
Use the βechoβ command and update the previously created file:
Step 6: Git Stash
Now, add all modifications to the temporary memory by executing the βgit stashβ command:
Step 7: Modify Existing File
Similarly, update the existing file through the below-given command:
Step 8: Staged Add Changes
Then, execute the βgit add .β command to add changes to the index:
Step 9: Apply Hold Changes
Next, apply the temporary keep changes on the Git repository through to the βgit stash applyβ command:
According to the below-provided output, the hold changes are not applied, and a conflict occurred:
Note: Now, to resolve the above-stated conflict, the user needs to add the changes to the Git repository by specifying the particular file name.
Step 10: Add Changes
Now, execute the βgit addβ command along with the particular file name in which changes are made:
Step 11: Apply Git Stash
Finally, apply the hold changes that are saved in the stash through the following command:
It can be observed that, the stash changes have been applied successfully:
Thatβs was all about resolving the stash conflict without commit in Git.
Conclusion
The unmerged conflict is encountered when multiple changes are performed by developers when they are working on a similar file. To resolve the Git stash conflict, they need to stage the added changes to the index without committing by running the βgit add <filename>β command. This guide illustrated the easiest solution to the Git stash conflict without commit.