How to alias 'git checkout' to 'git co'

48,891

Solution 1

The command:

git config --global alias.co checkout

will create a git alias to do that. It will add the following entry into your global ~/.gitconfig file:

[alias]
    co = checkout

Solution 2

Also, can edit this into your git config:

[alias]
   co = checkout
Share:
48,891

Related videos on Youtube

joseph.hainline
Author by

joseph.hainline

Digital Client Director by day. iOS, Ruby, Python, C++, C#, Flutter developer by night.

Updated on December 13, 2020

Comments

  • joseph.hainline
    joseph.hainline over 3 years

    I'd like the command git co to be the same as typing git checkout.

    A normal Bash alias (alias co='checkout') doesn't work.

  • John Szakmeister
    John Szakmeister over 11 years
    You don't need to do '!git'. You can just use 'co = checkout'. That prevents re-invoking git under another process... which can be advantageous on Windows where starting a new process is expensive.
  • fangzhzh
    fangzhzh almost 10 years
    for people who don't know where is git config: vi ~/.gitconfig or git config --global -e
  • Chris
    Chris over 2 years
    Find more details (and examples) in the manual here: git-scm.com/book/en/v2/Git-Basics-Git-Aliases