GN.
GN.

Reputation: 9869

Git alias errors out, while running it in CLI always works

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

When I alias it, in ~/.zshrc

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

and run it..

$ gam

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

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.

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

Upvotes: 0

Views: 191

Answers (1)

LeGEC
LeGEC

Reputation: 51988

The error message :

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

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

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


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.

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

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

# you can now run :
$ git gam

Upvotes: 2

Related Questions