Handy Git Shortcuts (Aliases) and How to Set Them Up

Felice Forby - Jul 8 '19 - - Dev Community

If you’re using git, these handy short codes will speed up your workflow. The following are the basic abbreviated git commands that are recommended on the git website. I'm always forgetting how to do this when I need to set up git on new computer so posting this as a reference.

  • co for checkout
  • br for branch
  • ci for commit
  • st for status

How to Set Up

To set up an alias, you use the git config command with the --global tag so that it applies to all of your git repositories.

$ git config --global alias.<YOUR CHOSEN SHORTCUT> <THE ORIGINAL GIT COMMAND>
Enter fullscreen mode Exit fullscreen mode

So to set up the basic shortcuts I mentioned above, open your terminal and put in the following:

git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
Enter fullscreen mode Exit fullscreen mode

Now your all set to go! You can use co in place of checkout and so on. For example, for git commit, you can now do something like this:

git ci -m "add CSS styles"
Enter fullscreen mode Exit fullscreen mode

See the official git documentation here.

. . . . . . . . . . . . . . . . . . . . . . . . .