I never run these two commands at work
git add . git commit -m 'my amazing changes'
Why? Because You can’t really see what you are committing. Everyday and every time I work on something in the office I make sure to commit changes this way (output trimmed)
git add -p [...] git commit -v [...]
git add with the
-p option triggers an interactive mode where you can walkthrough all of the hunks (changes) and stage, split, or ignore them. It's really powerful for reviewing your changes. When
git commit is run with the
-v option you get to see the changes that are about to be committed to the history. This a nice place for the final local review where you can easily eyeball all of the bits before it's pushed out. This method does not catch all of the bugs but it surely catches many silly mistakes.
If you don't like the concise commands you can also run
git add --interactive which gives you a more verbose text interface.
$ git add --interactive staged unstaged path 1: unchanged +2/-1 index.js 2: unchanged +2/-2 package.json *** Commands *** 1: status 2: update 3: revert 4: add untracked 5: patch 6: diff 7: quit 8: help What now>
I encourage you to stop running
git add . carelessly for new code changes and instead use the interactive mode to selectively add the changes you want then
git commit -v to commit and see the changes about to be added to the history. I can’t make any guarantees but I think you will end up liking this approach after a while.
This is really my personal opinion and does not necessarily reflect your experience. I hope still you can be a little bit open minded and try this approach to see if it works for you. If you don’t feel so comfortable with git, I would recommend try writing a local diary and register all changes you make, like fixing typos, line changes, file creations, etc. I found that helped me a lot in learning git.
Finally if you are into reading then you have to checkout the Pro Git book, which is actually a great resource and free.