Git/aliases

Contents

Git is a powerful tool with a lot of useful options. Did you know you can make an alias for a command and a set of options? You won't have to write long shell one-liners anymore. Below is a collection of some useful aliases.

A plain git diff shows the diff between the (unstaged) working copy and the staged working copy. In most cases this is the same as the diff between the working copy and the last committed revision of the current branch (HEAD).

However, if you have already done git add and then made some more changes, then the changes at time of last git add no longer show up in git diff. Use git diff --staged to create a diff between the already staged (but uncommitted) changes and the current HEAD.

Sometimes, you might have done something wrong in git. You think you've lost your commits, or something like that. Chances are, the information is still there--so the best course of action is to make
an immediate backup, before you risk actually losing data.