Can't pop git stash, 'Your local changes to the following files would be overwritten by merge'

For those who do have un-committed work, and want to pop their stash without losing that work, here is a way (with thanks to @iFreilicht):

  1. Temporarily stage any uncommitted changes:

     git add -u .
    
  2. Now you can apply your stash without git complaining (hopefully):

     git stash pop
    
  3. Now unstage everything, but leave the files as they are now:

     git reset
    

If step 2 couldn't patch cleanly due to conflicting changes, then you will need to resolve the conflicts manually. git diff should help you find them.


I got around this, I think it must have been some kind of bug, as my working directory was clean and up to date.

I ran git checkout . and after that git stash apply worked fine, I got everything back no problems at all. I'd be interested to work out what actually caused it to fail though.


The stash that was made with -u needs to have the untracked files cleaned away before being apply-ed (and pop is just apply+drop).

Out of general paranoia I'd mv the untracked files somewhere safe, then git stash apply, check everything carefully, and git stash drop once I'm sure I have it all correct. :-)