问题
I am trying to make an alias to delete a remote branch but I can't seem to get it, here is my latest attempt that I really expected to work but no luck.
rmrb = !git push origin :$1
I also tried, rmrb = branch -r -d but this doesn't do the same thing as git push origin :<branch>.
Does anyone know if this is possible or have an existing alias to do this?
回答1:
You just have to define it like this:
[alias]
rmrb = "push --delete origin"
And do git rmrb mybranch
回答2:
Maybe a shell function would be easier?
[alias]
rmrb = "!f() { git push origin :$1; }; f"
Or you can use sh:
[alias]
rmrb = !sh -c 'git push origin :$1' -
来源:https://stackoverflow.com/questions/9125156/git-alias-to-delete-remote-branch