How do you delete a remotes/origin/{branch}?
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 .
Here's the command to delete a branch remotely: git push <remote> --delete <branch> . The branch is now deleted remotely.
Let's break this command: First we get all remote branches using the git branch -r command. Next, we get the local branches not on the remote using the egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) command, Finally we delete the branches using the xargs git branch -d command.
use: git remote prune origin
or use git remote prune origin --dry-run
to preview what branches will be removed.
As in git help remote
prune
Deletes all stale remote-tracking branches under . These stale branches have already been removed from the remote repository referenced by , but are still locally available in "remotes/".
With --dry-run option, report what branches will be pruned, but do not actually prune them.
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