Creating Git aliases

To use Git more efficiently, you can create aliases, which are shortcut keywords for performing operations at a command prompt.

Note   You only need to perform the following procedure once on each client computer; the defined shortcuts are then available whenever the current user is logged in.

To create Git aliases

  1. In File Explorer, navigate to the top-level directory of the cloned Git repository on your local machine.
  2. Right-click the directory, and then click Git Bash Here on the shortcut menu.
  3. At the prompt, type the following commands:

git config --global alias.cm commit

git config --global alias.st status

git config --global alias.unstage 'reset HEAD --'

git config --global alias.last 'log -1 HEAD'

git config --global alias.up 'pull --rebase --autostash'

After entering these commands, you can then use the defined alias in place of the original command.

For example, instead of entering git status:

The git st alias now performs the same operation:

Aliases are especially helpful with lengthy commands, such as that used to rebase the local repository (which is helpfully reduced to the alias git up).

Now that you you've configured version control for your environment, let's look at how to minimize writing effort by single-sourcing project content.