Joao Albuquerque
Joao Albuquerque

Reputation: 466

"not a git command" configuring a bash script as a git alias

I want to set a specific alias in .gitconfig to a bash script like this:

[alias]
    example = "~/git-scripts/example-script.sh"

instead of:

[alias]
    example = "!f() { arg1=$1; echo $arg1; }; f"

So, the echo script above would be in this file ~/git-scripts/example-script.sh

When i'm trying to execute a alias like this, i got this error:

expansion of alias 'example' failed; ~/git-scripts/example-script.sh is not a git command

What's wrong?

Upvotes: 1

Views: 802

Answers (1)

Joao Albuquerque
Joao Albuquerque

Reputation: 466

As Charles Duffy said in the comments area, i could make it work like this:

[alias]
    example = "! ~/git-scripts/example-script"

Just add ! before the script path

Be careful with:

  1. Permissions: If you are in Linux, just add execution permissions like this:

    $ chmod +x YOUR_SCRIPT_PATH

  2. Notice that you don't need the extension (.sh) at the script file. You can read more about this here

Upvotes: 1

Related Questions