Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (19.4k points)

Failed Attempts to Delete Remote Branch

$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found.

$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found.

$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).

$ git push
Everything up-to-date

$ git pull
From github.com:gituser/gitproject
* [new branch] bugfix -> origin/bugfix
Already up-to-date.

What should I do differently to successfully delete the remotes/origin/bugfix branch both locally and remotely?

1 Answer

0 votes
by (27.5k points)


Deleting a remote branch:

git push origin --delete <branch> #git version 1.7.0 or new
git push origin :<branch>     #git version older than 1.7.0


Deleting a local branch:

git branch --delete <branch>
git branch -d <branch>                  #Shorter version
git branch -D <branch>                  #Force delete un-merged branches

Deleting a local remote-tracking branch:

git branch --delete --remotes <remote>/<branch>
git branch -dr <remote>/<branch>          #Shorter
git fetch <remote> --prune #Delete multiple obsolete tracking branches
git fetch <remote> -p                    #Shorter

Browse Categories

...