4 ms·
I hardly use stash any more. If I need to "stash" something, I just commit it. The reason this is okay is because we work on very small branches, with the aim o
by wldlyinaccurate 13y ago
I hardly use stash any more. If I need to "stash" something, I just commit it. The reason this is okay is because we work on very small branches, with the aim of squashing everything into a single commit before merging it with master. So it doesn't matter if I commit half-baked code to my branch, since it's going to be squashed anyway.
- lmm 13y agoI find that scenario makes me use stash much more - I usually have several branches on the go, so I can sometimes make changes while on the wrong one, at which point I'll stash and switch to the correct branch.
- saraid216 13y agoHuh. It's worth noting that you don't have to have a clean branch before you switch to another. You'll automatically shunt the changes to the new branch when you switch. I've often had the workflow of "make a bunch of changes on master; git checkout -b new_feature_branch; git commit -am 'save it off'; git checkout master". I haven't looked into the plumbing that goes into that, but I suspect it's actually stashing and popping for you.
- lmm 13y agoYeah, most of the time that works fine, but if my version of the branch I'm switching onto is behind then switching can induce "fake" conflicts; it's easier (I find) to just be in the habit of always stashing.
- ryanbrunner 13y agoThis is only true if one of the files that you've changed has 100% no changes between the branch you're currently on and the branch you're switching to. Even stuff that would normally be auto-merged will not allow you to switch branches. I still usually give it a try, and then stash when that gives me a problem. With 12 developers and some high-churn files, it's pretty common that 2 people are doing something with the same file, even with branches that only last 1-2 days.