

The file will then be edited by a developer, stashed, edited again and then made part of a commit. A commit with the message "First commit" occurs. Here is an example of a git stash merge conflict and the steps used to resolve it.įirst, initialize a Git repository, create a file and add it to the index. A developer must additionally run the git stash drop command to restore the state of the development environment to where it would be if the git stash pop conflict never happened. The pop command is a combination of git stash apply and git stash drop, but a conflict short-circuits the process and the drop command never runs. Once staged, the updated file will be included as part of the next commit.Ī noteworthy byproduct of a git stash pop conflict is the fact that the restored entry from the stash history isn't deleted. A developer will need to do this manually with the git add command.

Unfortunately, when the git stash pop conflict resolves, the merged file isn't staged. When a git stash pop conflict occurs, the developer must manually merge and resolve problems. Once they merge and save the file, they will have effectively resolved the git stash conflict. The only option for developers is to edit the file by hand and keep what they want and dispose of what they don't want. There's no magic remedy for such merge conflicts. The stash entry is kept in case you need it again. examples/git-stash/stash pop conflict (master)ĬONFLICT (content): Merge conflict in stash-pop-conflict.html Here is what a developer will see in the terminal window of a git stash pop conflict: Instead, Git populates the conflicted files with content from both the local working tree and the stash. But if a git stash pop conflict arises, then the problematic files won't be added to the index.

When the pop command runs, it's expected that files from the stash will overwrite the contents of the files in the local working tree, and the updated files will be staged in the git index.
#Stash changes github desktop how to#
Here's how to merge and resolve git stash pop conflicts when they arise, and clean up the stash history so it appears that the git stash conflict never actually happened. There's always the chance that a merge conflict might occur when a developer updates or overwrites a file.
