Linux – Unable to “git stash pop” due to conflict

command linegitlinuxunix

I have a local git repository and had several modified files. Then I needed to quickly produce a fix for something so I

  • stashed my changes (git stash)
  • edited file (vi file)
  • committed (git commit)
  • popped stash (git stash pop)

This resulted in Conflict.

# On branch master
$ git stash pop
Auto-merging page/search.php
CONFLICT (content): Merge conflict in page/search.php
$ git status
# On branch master
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   both modified:      page/search.php

If I try to cleanup the changes and re-apply stash, the same thing happens (conflict). I do not care much about the page/search.php, but I would like to get other files out from the stash.

Is there a way to convert stash into a patch or simply get the files as they were when stashed?

Best Answer

The stash has already been applied to other files; it is only page/search.php that you have to merge manually. Afterwards just run git reset to unstage the changes and keep on hacking – or git add ... and commit.

Related Question