186

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.

3 Answers 3

352

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
1
22

Also, can edit this into your git config:

[alias]
   co = checkout
2
  • 3
    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. Commented Jan 23, 2013 at 23:11
  • 6
    for people who don't know where is git config: vi ~/.gitconfig or git config --global -e
    – fangzhzh
    Commented May 20, 2014 at 2:00
0

simply to add some comments, the bash alias is for setting alias for a command, and the co or checkout is the parameter or flag to the command git, so it won't work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.