DEV Community

Cover image for How to master the art of Git

How to master the art of Git

Adnan Rahić on March 31, 2017

This article was first published on Medium. You can take a look at it here. Have you ever wondered how one learns to use Git well? You use Git ver...
Collapse
 
tbroyer profile image
Thomas Broyer

git add -A is an anti-pattern, please don't recommend it as a rule of thumb!

Use git status to list files and git add for each file you want/need to add. Then learn about git add -i (or git add -p), or use GUIs for a point-and-click UX (I personally use git citool most of the time, and git add -p when I need to edit a hunk, but this is quite rare).

The rule of thumb really is not to forget that this is about "version control" (like any VCS), and not some backup tool. Commits, commit logs and commit history need to be crafted with care and love, for your coworkers/contributors, and your future self.

Learn about the existence of git blame and git bisect (assuming you already know and use git log and/or gitk or similar tool) to understand why a clean history is good for you.

Those are my advice.