Table of Contents

Git Aliases

Git aliases are custom commands that simplify and streamline your Git workflow. They act as shortcuts for longer or more complex Git commands.

How to Create Git Aliases

You can create aliases at the global, local, or system level. The most common is the global level.

To create a global alias:

git config --global alias.<alias_name> <git_command>

For example, to create an alias `co` for `checkout`:

git config --global alias.co checkout

To create a local alias, omit the `–global` flag.

Examples of Useful Git Aliases

Here are some commonly used Git aliases:

  git config --global alias.st status
  git config --global alias.br branch
  git config --global alias.cm commit
  git config --global alias.co checkout
  git config --global alias.pl pull
  git config --global alias.ps push
  git config --global alias.last 'log -1'
  git config --global alias.graph 'log --pretty=format:"%Cred%h%Creset -%d %s %Cgreen(%cr) %C(bold blue)%an%Creset" --graph --abbrev-commit'
  git config --global alias.amend 'commit --amend'
  git config --global alias.rebase 'rebase master'

Tips for Effective Alias Usage

Additional Notes

By effectively using Git aliases, you can significantly enhance your Git productivity and reduce typing time. Experiment with different aliases to find the perfect combination for your workflow.