Git
Some rules of thumb:
Don’t use
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.Don’t use
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 likegit fetchandrebase. You can also usegit 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 statusandgit diffto decide what to commit. Adding a-vflag togit 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.-por--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.