<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi all,</div><div>I'm working a lot with git stash.</div><div>This is because while fixing a problem, my analysis lead me thru another piece of code and other problems that I fix too, and at the end, I have a bunch of changes.</div><div>I don't want to commit each single fix, because they are often partial, not well ordered and it would mean rewriting history thru git rebase -i which is OK for not too complex mess, but not that great for interactivity.</div><div>It's much much more simple and interactive to have a pool of changes in the working copy, selectively pick some feature to stage via a good GUI client (sourceTree works well for me), stash the rest to check if compilation OK, etc...</div><div><br></div><div>I even often maintain a stack of stashes for different features.</div><div>For example, I have stashed changes for FloatMathPlugin fixes that I want to be integrated when I compile my own VM, but that I don't want to commit into another feature branch. since git 2.13 it's as simple as</div><div><br></div><div>    git stash push -m "FloatMathPluginFix" platforms/Cross/plugins/FloatMathPlugin/<br></div><div><br></div><div>That's very lightweight compared to having specific branches for doing the merge...<br></div><div><br></div><div>Oui mais voilà, each time I commit, merge or checkout a new branch, my latest stash is popped which mean applied when I don't want to, and removed from my stack of stashes which I ABSOLUTELY do not want to!</div><div>More other, when attempting a rebase -i, I often encounter undesired side effects...<br></div><div>This is really annoying/completely disrupting my own workflow.</div><div>After searching the root cause on forums, I finally discovered the source of my problems: .git/hooks/post-checkout same for post-commit post-merge<br></div><div><br></div><div>It performs a git stash (save), checkout/commit/merge, then git stash pop.</div><div>Err, except that if there is nothing to save, git stash does nothing, but still, git stash pop will pop one of my carefully crafted feature stash.</div><div>This is exactly as described in an answer to</div><div><a href="https://stackoverflow.com/questions/27697835/stash-branch-working-copy-confusion">https://stackoverflow.com/questions/27697835/stash-branch-working-copy-confusion</a></div><div><br></div><div>As suggested in this answer, git stash pop should be perform if AND ONLY IF git stash save changed the SHA1!</div><div>I don't really know how to do that, but would greatly appreciate if the author of these hooks would help me fixing this mess :)<br></div></div></div></div>