DEV Community

Felice Forby
Felice Forby

Posted on • Updated on

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

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.

Top comments (4)

Collapse
 
netmailgopi profile image
Gopi Ravi

Interesting. Was thinking it's gonna be terminal aliases. Didn't know git aliases were a thing. Will attempt it today. Thank you

Collapse
 
morinoko profile image
Felice Forby

Yeah, they are really handy. I feel like it speeds up my workflow a lot. If you do a bit more research, you can find a lot more suggestions for convenient aliases that other developers use too!

Collapse
 
macginitie profile image
Andrew MacGinitie

nice! I <3 me some 2-letter commands ;-) thanks!

Collapse
 
morinoko profile image
Felice Forby

You are welcome! Thanks for reading!