Git alias to delete remote branch

∥☆過路亽.° 提交于 2019-12-04 19:43:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!