Reputation: 561
I was working on some proof-of-concept code and had created a branch for it. Since it took close to 2 weeks, i was also pushing it to the remote on a daily basis.
The POC is now done and I do not want to merge it.
I was able to delete the local branch with
git branch -D <branchname>
But when i try to push it fails with the merge error (Branches cannot be deleted until merged). Is there a way to delete unmerged branches remotely?
Upvotes: 1
Views: 3171
Reputation: 1089
In Git, local and remote branches are separate objects. Deleting a local branch doesn’t remove the remote branch.
To delete a remote branch, use the git push command with the -d (--delete) option:
git push remote_name --delete branch_name
Where remote_name is usually origin:
Output:
...
- [deleted] branch_name
There is also an alternative command to delete a remote branch, that is, at least for me harder to remember:
git push origin remote_name :branch_name
Upvotes: 2
Reputation: 142552
Is there a way to delete unmerged branches remotely?
git push :origin/branch
# or
git push origin --delete branch
According to your comments, you cant do it on bitbucket, the reason can be since your administrator blocked the option to delete branches
Prevert Deletion in the following screenshot
Upvotes: 3