git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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)

Next: Neal Kreitzinger
Message 1 of 4 in “Stash during incomplete merge”
  1. Phil HordFeb 26, 2012
  2. Neal KreitzingerFeb 28, 2012
  3. Neal KreitzingerFeb 28, 2012
  4. Neal KreitzingerFeb 29, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.