Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git alias to delete remote branch

Tags:

git

alias

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?

like image 209
keegan3d Avatar asked Feb 03 '12 07:02

keegan3d


People also ask

How do I remove a remote git branch?

To completely remove a remote branch, you need to use the git push origin command with a -d flag, then specify the name of the remote branch. So the syntax representing the command for removing a remote branch looks like this: git push origin -d branch-name .

Can you delete a branch in remote?

In review, the steps to delete remote Git branches are: Issue the git push origin –delete branch-name command, or use the vendor's online UI to perform a branch deletion. After the remote branch is deleted, then delete the remote tracking branch with the git fetch origin –prune command.

How do I delete a remote branch without deleting locally?

How to Delete a Branch Remotely. You'll often need to delete a branch not only locally but also remotely. To do that, you use the following command: git push <remote_name> --delete <branch_name>.

How do I remove a remote branch code?

To delete a remote branch, you can't use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name ( origin in this case) after git push .


1 Answers

You just have to define it like this:

[alias]
    rmrb = "push --delete origin"

And do git rmrb mybranch

like image 169
manojlds Avatar answered Sep 20 '22 19:09

manojlds