Some rules of thumb:
git add .. It will probably bite you into adding to much stuff – creating commits exaclty with what you want is a better habit to get.
git pullto retrieve the content of shared branches. A typical example is to commit on a branch, try to push it to GitHub, which refuse the push because it is not a fast-forward one. If you simply pull, you’ll create a merge commit, which is probably not needed.
Instead, use something like
rebase. You can also use
git pull --ff-onlyto “tentatively” pull, i.e. fail if it is not a fast forward (in that case the remote tracking branch is already updated locally).
Before creating a new commit, use
git diffto decide what to commit. Adding a
git commitis also an option to review what you are committing.
Before pushing a set of commits to GitHub, use
git logand its variants (e.g.
--graph) to review what you will share.
Some rules above could be rephrased as: use commands that have the precise result you want (instead of commands with multiple kinds of results). Or: double check that what you want to persist in the history, and share with others, are really what you wanted.