Lab 9: How to Setup Aliases and Shortcuts for Git Commands

Git aliases can be used to execute commands without writing the full command.

Windows users can run the following commands to setup the aliases.

git config --global checkout
git config --global commit
git config --global status
git config --global branch
git config --global alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
git config --global alias.type 'cat-file -t'
git config --global alias.dump 'cat-file -p'

Otherwise you could edit the .gitconfig file in your $HOME directory to setup the aliases. Add the following code in the .gitconfig file.

  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
  type = cat-file -t
  dump = cat-file -p

Note: For Windows users the HOME directory is ususally at C:\Users\

Here’s how my .gitconfig file looks after adding the aliases.

Git config

Other related posts:
Git Delete a Local or Remote Branch
How to Clone a Git Repository into a Specific Folder?
Change the URI for a Remote Git Repository
How to Merge a Local Git Branch with Master
How to create a .gitignore file in Windows

This content has been helpful to you?

Thanks for contributing!

Yes No