Deleting remote branches 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 .
If you are sure you want to delete it, run ' git branch -D issue-5632 '. This error is caused because we have some un-merged changes in branch issue-5632 due to which the branch delete has failed. In such case either you can delete the branch forcefully or merge the changes and then perform the delete operation.
Deleting a branch LOCALLY Delete a branch with git branch -d <branch> . The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet. The branch is now deleted locally.
The command to delete a local git branch can take one of two forms: git branch –delete old-branch. git branch -d old-branch.
The fact that refs/remotes/origin/my_remote_branch
exists in your local repository does not imply refs/heads/my_remote_branch
exists in the origin
remote repository.
Do git fetch -p origin
to make refs/remotes/origin/my_remote_branch
go away if it's already deleted in origin. The -p
option tells fetch to delete any tracking branches that no longer exist in the corresponding remotes; by default they are kept around.
Found question cleaning up old remote git branches and this did the trick
git branch -r -d origin/my_remote_branch
I ran across this when trying to delete a remote branch that had already been deleted. All that was needed was a prune:
git remote prune origin
Try following two options to delete remote branch forcibly
Option 1
get push origin --delete <branchName>
Option 2
git fetch -p origin
git branch -r -d origin/<branchName>
git branch -r -d origin/my_remote_branch
was not enough for me. Before I had to go to server and work with git directory directly (which is dangerous and ugly) to remove the branch:
ssh mygitserver
su - git
cd /home/git/repositories/my_remote_branch.git/
git --git-dir=. --work-tree=/tmp/ branch -D my_remote_branch
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