views:

65

answers:

1

Hello!

I am running msysgit 1.7.3.1. If I run stash apply, and there is a conflict, all of my stash changes get staged. Is this the correct behaviour? I found it a little surprising.

Another question: if I have stashed 10 files, and there is a conflict in one of them, will stash apply abort when it has a conflict, or will it apply all non-conflicted files.

Finally, if I do the following:

git stash
git pull
git stash apply

and another developer has removed a file that I have stashed, then I am unable to apply the stash on this file. How can I retrieve my changes from the stash?

Thanks!

A: 

the index is used to indicate that these files did not have conflicts. Your conflicted files should not be in the index.

re the 10 files. Stash will add the remaining 9 to the index. Fix the conflict in the remaining file. Add it to the index. Then commit.

re the changes from the stash that are missing. You can get your file by doing a git checkout (stash-SHA1 or other reference to it>) -- filespecification

you can also change your stash to a branch which you then can checkout and do more things with.

hope this helps

adymitruk
OK, I understand. The index is used to track files that don't have conflicts. However, my workflow is normally like this:
Jacko
my workflow is normally like this: 1) working on something, so working dir is dirty 2) want to pull someone's changes 3) stash 4) pull 5) stash apply 6 continue working. I am not usually ready to commit after stash apply, that is why having my stash files staged is unexpected.
Jacko
And thanks for the explanation, btw.
Jacko
The fact that the stashed changes that are applied are in the index is by design. When you continue working, that work will not be staged. This way you can differentiate between what you did since applying the stash.
adymitruk
ahhhhhh, now that makes sense. Is this fact part of the git oral tradition, passed down from father to son, or is it written out somewhere? I couldn't find such in the man pages, or combing through the web. Thanks for the info!!!!
Jacko
wait a minute, admitruk, I think you're giving two different explanations for why stash puts nonconflicted changes in the index.
Jacko
1) to differentiate between conflicted and non-conflicted changes and 2) to differentiate between stashed changes and subsequent changes. #1 makes sense, but if #2 was true, then changes would be indexed even without conflicts, which doesn't happen. I wish the documentation addressed this issue......
Jacko
Time to consult #irc :)
adymitruk