Uncommitted changes remain in your worktree or index until you tell git where to commit them.
git add
, git checkout
and git reset
all have a --patch
option. The workflow is, doing what needs doing and recording it where it needs recording are separate tasks. Often enough you find yourself doing effectively drive-by bugfixing, where you find a complete mess someoneusually me left and the issue is, there's doing the work, and doing the paperwork, but you're staring right straight at the work and know exactly what needs doing.
The git way1 is, Do It. Get it all correct in your worktree (this may involve a bit of exploratory branching itself)
- and then construct the commit series you'd have constructed in the first place if you'd known exactly what you were doing all along.
That's the important part. That's what makes professional, publishable work. What trips people up is, git's meant at least as much for the messy part that comes before that.
1hahaha he said "the git way", as if there were only onelol
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…