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?


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.

  • Yes. Exactly. After i recovered the patch with -p, I found out that other files are already updated. – romaninsh Jan 17 '12 at 16:25
  • 3
    very nice, git stash pop, resolve your conflicts then git add x then git reset to get it out of staging, Thanks! – Quang Aug 21 '12 at 4:33
  • @Quang There should be a stash pop --continue which aliases to reset. :) – Kaz Oct 11 '13 at 0:52

Resolved with:

git stash show -p
  • That saved my day, =) – anatoly techtonik Apr 17 '15 at 9:16
  • Does -p do anything here? – Joost Oct 24 '16 at 12:37
  • 2
    show? -p ? what this does? how "show" could be related to resolve conflicts? – Arnold Roa Apr 28 '17 at 15:04
  • 1
    This command shows the changes made in the stash, allowing you to manually merge – Desmond Weindorf May 17 '18 at 17:31
  • I found git stash show -p | git apply && git stash drop from coderwall.com/p/anxp0g/force-a-git-stash-pop, and I'm trying to verify it will work before I run it. :-) – PatS Aug 1 '18 at 20:40

After the git stash pop command, you then have to resolve the conflict by hand then do git stash drop manually as the man git-stash suggests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.