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.
Git: how to use stash
21–30 of 43 posts
Re: Git: how to use stash
#22I 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.
I 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.
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.
Re: Git: how to use stash
#23Re: Git: how to use stash
#24Curious.... why not use feature branches for absolutely everything and follow the git flow and treat hot fixes as prescribed?
git add -p
git stash
test
commit
git stash popRe: Git: how to use stash
#25Earlier quoted context omitted.
I 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.
Huh. 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 an…
Re: Git: how to use stash
#26Earlier quoted context omitted.
I 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.
Huh. 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 an…
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.
Re: Git: how to use stash
#27Far better: git commit -a -m 'Work in progress' Switch to other branch, do work on it. When you come back to the branch, git reset --soft HEAD^ It's far less volatile than stash, and far better at keeping WIP in the right place when things get so hectic that you have abandoned work on more than one branch. Stash is only really safe to use for very short-lived uses, such as "stash/pull/unstash"
Personally, if I'm on a local branch I don't care, but I guess it might bother some people.
Re: Git: how to use stash
#28Re: Git: how to use stash
#29Curious.... why not use feature branches for absolutely everything and follow the git flow and treat hot fixes as prescribed?