DEV Community

Discussion on: Plan Your Commits

Collapse
 
cburschka profile image
Christoph Burschka

I haven't done really well at working on one thing at a time, so by the time I'm ready to commit my work tree tends to be pretty cluttered with changes.

So I always use -p to selectively stage stuff, making multiple commits after everything is done. Even if the same code is touched by multiple unrelated changes (eg. refactoring or code style), I try to edit the diff to make sure each commit only does what it should. And on the reverse side, if an unpushed commit has an error, I'll rebase or amend before pushing.

Being able to juggle multiple change sets locally and organizing stuff before making the final push is really one of the most powerful parts of git.