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

GitAliasGit Alias

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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 - Git

Also, can edit this into your git config:

[alias]
   co = checkout

Solution 3 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionjoseph.hainlineView Question on Stackoverflow
Solution 1 - Gitjoseph.hainlineView Answer on Stackoverflow
Solution 2 - GitsmaView Answer on Stackoverflow
Solution 3 - GitccjliView Answer on Stackoverflow