In Git, I want to add some global aliases for convenience.
The command
git config --global alias.unstage 'reset HEAD --'
as found in the documentation, works fine. So I tried using that same syntax, with a !
prepended to the command, to run external, more complex scripts:
# release-major
latest=$(git describe --abbrev=0 --tags 2>/dev/null); latest=${latest:-v0.0.0}; components=(${latest//./ }); major=${components[0]}; major=${major//v/}; minor=${components[1]}; patch=${components[2]}; major=$((major+1)); minor=0; patch=0; next='v'$major'.'$minor'.'$patch; git tag -a $next -m ""
# release-minor
latest=$(git describe --abbrev=0 --tags 2>/dev/null); latest=${latest:-v0.0.0}; components=(${latest//./ }); major=${components[0]}; major=${major//v/}; minor=${components[1]}; patch=${components[2]}; minor=$((minor+1)); patch=0; next='v'$major'.'$minor'.'$patch; git tag -a $next -m ""
# release-patch
latest=$(git describe --abbrev=0 --tags 2>/dev/null); latest=${latest:-v0.0.0}; components=(${latest//./ }); major=${components[0]}; major=${major//v/}; minor=${components[1]}; patch=${components[2]}; patch=$((patch+1)); next='v'$major'.'$minor'.'$patch; git tag -a $next -m ""
If I try to add these three scripts with the syntax
git config --global alias.my-alias-name '!my-alias-code'
however, it doesn't work. The result is always a parser error.
I tried every variation of quoting, unquoting, single quotes and double quotes that I could imagine. I even tried adding these to the .gitconfig
file directly. None of that works.
What am I missing? How can these scripts be fixed so that I can add them as aliases?