简体   繁体   中英

"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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM