Git alias to delete remote branch
Question
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?
Solution
You just have to define it like this:
[alias]
rmrb = "push --delete origin"
And do git rmrb mybranch
OTHER TIPS
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' -
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow