Give yourself as many chances as you can to catch your mistakes before you push them:
- Use an editor plugin like Sublime Text's GitGutter so you can always see which parts of a file you've changed. (More precisely, it shows the diff of the file between the working directory and HEAD.)
- Not sure whether to stage your unstaged changes? Use
git diff
with no arguments. It shows the difference between your working directory and the index. - Not sure whether to commit your staged changes? Use
git diff --staged
. It shows the difference between your index and HEAD. - When you decide to commit, use
git commit --verbose
, no-m
, and take one last look at the changes in your editor. (Make sure it's got a nice Git Commit Message syntax, like the one in the Sublime Text Git package, so the list of changes is nice and colorized.) You can't edit the changes directl