Split work into separate commits. You've probably many times opened a file to write a single-line fix, but at the same time you spotted that the formatting was wrong, some documentation could be improved, or some other unrelated fix. With other RCSs you'd have to write that down or commit it to memory, finish the fix you came for, commit that, and then return to fix the other stuff (or create a ball-of-mud commit with unrelated stuff). With Git you just fix all of it at once, and stage+commit the single line separately, with git add -i
or git-gui
.
Don't break the build. You're working on a complicated modification. So you try different things, some of which work better than others, some which break things. With Git you'd stage things when the modification made things better, and checkout
(or tweak some more) when the modification didn't work. You won't have to rely on the editor's undo functionality, you can checkout
the entire repo instead of just file-by-file, and any file-level mistakes (such as removing a file that has not been committed or saving+closing after a bad modification) does not lead to lots of work lost.
git add -p
, you can choose to commit one piece of a file while not committing another piece of the same file.git status
and possiblygit push
. For all the hype about git, (and GitHub sharing code is wonderful) parts are very annoying