如何将“git checkout”别名为“git co”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14489109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:19:21  来源:igfitidea点击:

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

gitaliasgit-alias

提问by joseph.hainline

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

我希望命令git co与键入相同git checkout

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

普通的 Bash 别名 ( alias co='checkout') 不起作用。

回答by joseph.hainline

The command:

命令:

git config --global alias.co checkout

git config --global alias.co checkout

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

将创建一个 git 别名来做到这一点。它将以下条目添加到您的全局~/.gitconfig文件中:

[alias]
    co = checkout

回答by sma

Also, can edit this into your git config:

此外,可以将其编辑到您的 git 配置中:

[alias]
   co = checkout

回答by ccjli

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.

简单地添加一些注释,bash 别名用于为命令设置别名,而 co 或 checkout 是命令 git 的参数或标志,因此它不起作用。