Git 别名错误,而在 CLI 中运行它始终有效 [英] Git alias errors out, while running it in CLI always works

查看:34
本文介绍了Git 别名错误,而在 CLI 中运行它始终有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 CLI 中运行 $ git commit --amend --no-edit 工作.

Running $ git commit --amend --no-edit in the CLI works.

当我给它取别名时,在 ~/.zshrc

When I alias it, in ~/.zshrc

alias gam="git commit --amend --no-edit"

并运行它..

$ gam

fatal: Stray .git/rebase-apply directory found.
Use "git am --abort" to remove it.

我运行 git am --abort 然后尝试再次运行别名 gam..

I run git am --abort then try to run the alias gam again..

$ gam

它只是挂起……永远不会完成.

It just hangs... and never completes.

所以我杀死它并再次运行它......结果

So I kill it and run it again.. which results in

fatal: Stray .git/rebase-apply directory found.
Use "git am --abort" to remove it.

在 CLI 中直接运行命令时,为什么别名会搞砸?

Why would the alias mess things up, while running the command straight in the CLI work?

推荐答案

错误信息:

使用git am --abort";删除它.

Use "git am --abort" to remove it.

提到了 git am,它根本不应该被 git commit --amend --noedit 触发.

mentions git am, which shouldn't be triggered at all by git commit --amend --noedit.

您的别名可能被其他东西(另一个别名?zsh 函数?)接管,它试图运行 git am .

Your alias is probably taken over by something else (another alias ? a zsh function ?) which tries to run git am <something>.

检查您的 zsh 设置:我知道在 bash 中使用 type gam 以获得调用 gam 时目标内容的准确描述;我不精通 zsh,请尝试以下方法之一:whence gamtype gamwhich gam.

Check your zsh setup : I know of type gam in bash to get an accurate description of what is targeted when invoking gam ; I'm not fluent in zsh, try one of the following : whence gam, type gam or which gam.

一旦你发现了冒犯者,要么删除冒犯的名字,要么为你自己的命令选择另一个别名.

Once you have spotted the offender, either remove the offending name, or choose another alias for your own command.

按照@torek 的建议,您还可以定义一个 git 别名:

As suggested by @torek, you can also define a git alias :

$ git config alias.gam 'commit --amend --noedit'

# you can now run :
$ git gam

这篇关于Git 别名错误,而在 CLI 中运行它始终有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆