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?
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 .
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 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>.
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 .
You just have to define it like this:
[alias]
rmrb = "push --delete origin"
And do git rmrb mybranch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With