3 ms·
> You only need to commit or stash if there are conflicts Unless you're wanting to take a look at the other branch clean, then you have to stash or do the extr
by afro88 10y ago
> You only need to commit or stash if there are conflicts
Unless you're wanting to take a look at the other branch clean, then you have to stash or do the extraneous commit. Most of the time I change branches to check someone else's work, or compare something that isn't working to develop/master. The stash/commit dance is a regular annoyance for me
- dahart 10y agoThis is true, you have to stash or commit, if you want to go to another clean branch. But, your code is going to be committed & rebased later in your own branch anyway, right? If you commit some partial changes & later come back, make some more commits, and rebase/squash before pushing, you haven't done anything extra you wouldn't have done anyway. By stashing, going away, then coming back, popping, working, committing, rebasing & pushing, you've added extra steps to the general case by involving stash, and you've added an extra failure point. If you commit instead, your changes are already there when you come back, and they stay associated with your branch while you're gone. It's harder to forget what you were doing, and it's much harder to lose your work accidentally if you commit. I've witnessed the exact scenario you describe go bad several times when people go code review or test someone else's code, and the forget what they were doing. Sometimes people will stash again while working in someone else's branch, making it hard to keep track of which stash is which. That can lead to accidentally dropping stashes, or to popping the wrong stash. Try only using 'git commit -am "WIP"' as a git stash replacement for a while and see if it really is any harder than stashing. To uncommit a WIP commit (which is always optional -- you could wait until you rebase -i) just 'git reset --soft HEAD^'.