You can make this work just fine. You just need to add a missing '-' at the end of your definition. The '-' will signal to bash that all option processing is done, and anything that comes after becomes a parameter you can reference via $1
, $2
, etc:
[alias]
nuke = !sh -c 'git branch -D $1 && git push origin :$1' -
From the command line, switch to another branch, then run the command:
git nuke branch-name
Alternately… If you are unable to add the above to your .gitconfig
file for some reason, but have access to the .bashrc
, .bash_profile
, etc… you can add the following:
git config --global alias.nuke '!sh -c "git branch -D $1 && git push origin :$1" -'