我无法使用我的git别名

时间:2016-12-20 19:16:02

标签: linux git ubuntu

如何使用git别名?

我已在~/.gitconfig中配置了它们:

[alias]
    g = "git"
    go = "git checkout"

我可以通过git config --get-regexp alias看到它们:

alias.g git
alias.go git checkout

但是当我尝试使用它们时,会显示以下内容:

$ g
g: command not found

$ go
The program 'go' is currently not installed. You can install it by typing:
sudo apt install golang-go

我如何让他们工作?

3 个答案:

答案 0 :(得分:1)

git别名不是那样使用的。 git别名用于git,意思是:

你的别名文件应该是:

    [alias]

        co = checkout

并像git co <args>

一样使用

别名仅用于after'git'命令。

答案 1 :(得分:0)

您必须输入

git g

git go

答案 2 :(得分:0)

首先,正如另一位用户指出的那样,你必须只在git中使用git别名。这意味着您的别名必须如下所示:

git ALIAS ...

然后,不要在你的别名周围加上任何“”(但你可以,它没有任何问题)。就像这样写:

[alias]
    co = checkout
    ci = commit
    st = status

如果你想设置别名来调用git,你必须将它们添加到〜/ .bashrc文件中。

alias gs='git status'
alias go='git checkout'

希望有所帮助