Stash during incomplete merge
- From
Phil Hord <hordp@cisco.com>
- Date
- Feb 26, 2012, 18:36 UTC
- Message-ID
- <4F4A7BC7.5010702@cisco.com>
Hi list,
I was cherry-picking changes from an old branch recently when I ran into unexpected behavior with git stash pop. When I git-stash-save after resolving a merge-conflict, the subsequent git-stash-pop does not restore my index.
I think it is the same problem being asked about here: http://stackoverflow.com/questions/9009354/git-stash-during-a-merge-conflict
Is this expected behavior or a bug?
<http://stackoverflow.com/questions/9009354/git-stash-during-a-merge-conflict>Here's a script the demonstrates the anomaly, but my actual encounter involved more files, some of which I added to the index and some I did not:
# Create a sample merge-conflict git init tmp-repo && cd tmp-repo echo foo > foo.txt && git add foo.txt && git commit -m "foo" git checkout -b A master && echo foo-A > foo.txt && git commit -am "foo-A" git checkout -b B master && echo foo-B > foo.txt && git commit -am "foo-B" git merge A git status # Resolve the conflict echo foo-AB > foo.txt && git add foo.txt git status git stash # test test test... Resume... git stash pop
Here's some of the final output:
$ git merge A Auto-merging foo.txt CONFLICT (content): Merge conflict in foo.txt Recorded preimage for 'foo.txt' Automatic merge failed; fix conflicts and then commit the result.
$ git status # On branch B # Unmerged paths: # (use "git add/rm <file>..." as appropriate to mark resolution) # # both modified: foo.txt # no changes added to commit (use "git add" and/or "git commit -a")
$ # Resolve the conflict $ echo foo-AB > foo.txt && git add foo.txt $ git status # On branch B # Changes to be committed: # # modified: foo.txt #
$ # Now foo.txt is in my index. But I have to test something before I commit. $ git stash Saved working directory and index state WIP on B: 80f2a13 foo-B HEAD is now at 80f2a13 foo-B
$ # test test test... Resume... $ git stash pop
# On branch B # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: foo.txt # no changes added to commit (use "git add" and/or "git commit -a") Dropped refs/stash@{0} (460a6d5c67a3db613fd27f1854ecc7b89eeaa207)