2 ms·
What things about the staging area do you dislike at a fundamental level (i.e. going beyond a one-off cost of having to memorize a quirk)?
by patrec 6y ago
What things about the staging area do you dislike at a fundamental level (i.e. going beyond a one-off cost of having to memorize a quirk)?
- lmm 6y agoI dislike that in general, if I've started working on the wrong branch, I can't losslessly switch to a different branch. If I try to check out another branch directly git might (or might not) tell me I need to stash instead. But if I do stash then I lose the distinction between staged and unstaged changes.
- patrec 6y agoI think this should work fine (modulo typical git ui infelicities; but you can certainly make an alias that does it). How about something along the lines of: git stash --keep-index git stash git checkout right-branch git stash pop --index git stash pop ? Untested, so I might have messed up a detail. Another alternative is creating a tmp branch (again untested) and cherry-picking (with --no-commit) across. git checkout -b tmp git commit -m 'staged' git commit -am 'unstaged' git checkout right-branch git cherry-pick -n tmp git reset HEAD git cherry-pick -n tmp^ git branch -D tmp