如何删除git别名?

Day*_*uck 75 git alias

我正在学习使用git,我尝试设置一些像这样的别名:

git config --global alias.trololo 'status'
Run Code Online (Sandbox Code Playgroud)

所以现在当我输入git trololo它时就像git status.

现在不需要trololo别名.我怎样才能正确删除它?

Von*_*onC 114

您可以尝试--unsetgit config:

git config --global --unset alias.trololo
Run Code Online (Sandbox Code Playgroud)

我觉得比直接编辑配置文件更安全(git config --global --edit)

  • 除了是执行此操作的正确方法之外,如果您使用适当的标志(“--local”等),此解决方案还具有适用于本地和系统别名以及全局别名的优点。 (2认同)

atu*_*pal 13

要不就:

vim ~/.gitconfig
Run Code Online (Sandbox Code Playgroud)

并删除别名行.


小智 13

如果有人为同一个别名拥有多个值并且具有:

$ git config --global --unset alias.trololo
warning: alias.trololo has multiple values
Run Code Online (Sandbox Code Playgroud)

使用 --unset-all


Cod*_*nda 6

您可以通过从配置文件中删除该行来删除它,或者您可以尝试以下操作:

git config --global --unset alias.YourAlias
Run Code Online (Sandbox Code Playgroud)