Unable to "git stash pop" due to conflict

65,581

Solution 1

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.

Solution 2

Resolved with:

git stash show -p

Solution 3

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.

Share:
65,581

Related videos on Youtube

Chris Alonga
Author by

Chris Alonga

Programmer for 20y (since I was 11). Architect/Lead for hundreds of complex web projects. Open-Source Project I have created Agile Toolkit (atk4) in 2011 and currently work on "Agile Data" project. Join as contributor. (My Blog)

Updated on September 18, 2022

Comments

  • Chris Alonga
    Chris Alonga over 1 year

    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?

  • Chris Alonga
    Chris Alonga over 12 years
    Yes. Exactly. After i recovered the patch with -p, I found out that other files are already updated.
  • Quang
    Quang almost 12 years
    very nice, git stash pop, resolve your conflicts then git add x then git reset to get it out of staging, Thanks!
  • Kaz
    Kaz over 10 years
    @Quang There should be a stash pop --continue which aliases to reset. :)
  • anatoly techtonik
    anatoly techtonik about 9 years
    That saved my day, =)
  • Joost
    Joost over 7 years
    Does -p do anything here?
  • Arnold Roa
    Arnold Roa about 7 years
    show? -p ? what this does? how "show" could be related to resolve conflicts?
  • Desmond Weindorf
    Desmond Weindorf about 6 years
    This command shows the changes made in the stash, allowing you to manually merge
  • PatS
    PatS almost 6 years
    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. :-)