简体   繁体   English

我不能使用我的git别名

[英]I can't use my git alias

How to use the git alias? 如何使用git别名?

I have configured them in ~/.gitconfig : 我已经在~/.gitconfig配置了它们:

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

And I can see them with git config --get-regexp alias : 我可以用git config --get-regexp alias看到它们:

alias.g git
alias.go git checkout

But when I try to use them, it displays the following: 但是当我尝试使用它们时,它将显示以下内容:

$ g
g: command not found

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

How cai I make them to work? 我怎么才能让他们工作?

git alias are not used like that. git别名不是那样使用的。 git aliases are used for git, meaning: git别名用于git,意思是:

your alias file should be something like: 您的别名文件应类似于:

    [alias]

        co = checkout

and be used like git co <args> 并像git co <args>

the alias is used only for the after 'git' command. 别名仅用于'git'之后的命令。

You have to type 您必须输入

git g

or 要么

git go

First, as another user pointed out, you have to use git aliases only inside git. 首先,正如另一个用户指出的那样,您必须仅在git内部使用git别名。 What it means is that your aliases must be used like this : 这意味着您的别名必须这样使用:

git ALIAS ...

Then, don't put any " " around your aliases (but you could, there's nothing wrong with it). 然后,不要在别名周围放置任何“”(但是您可以,没有问题)。 Just write them like this : 像这样写它们:

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

If you want to setup aliases to call git with, you have to add them to your ~/.bashrc file. 如果要设置别名以调用git,则必须将它们添加到〜/ .bashrc文件中。

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

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到我的git储存库网址 - Can't find my git repository url 在BASH中,我需要根据perl脚本的输出来更改一些环境变量。 在tcsh中,我可以使用别名eval组合。 不能狂欢 - In BASH I need to change some environment variables based on output of a perl script. In tcsh I can use an alias eval combo. Can't in bash Git 上 Linux 完好。 我无法将提交推送到我的 GitHub 帐户。 终端坏了 - Git on Linux MInt. I can't push commit to my GitHub account. Terminal breaks down 我可以提供裸git储存库吗? - Can I serve my bare git repository? 我可以使用参数做别名吗? - Can I make an alias with a parameter? 如何在git或shell别名中使用`find -exec sh -c` - How to use `find -exec sh -c` in a git or shell alias Rails / Git:无法将Rails代码推送到服务器(&#39;〜/ git / myapp.git&#39;似乎不是git存储库) - Rails/Git: can't push my rails code out to the server ('~/git/myapp.git' does not appear to be a git repository) 如何将输入令牌传递给zsh别名中的嵌套命令 - How can I pass my input token to a nested command in a zsh alias 使用initramfs时,为什么不能用PARTUUID指定rootfs? - Why can't I specify my rootfs with PARTUUID when I use initramfs? 如何确定我的 git repo 所在的 URL? - How can I determine the URL my git repo is located?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM