Delete a git branch locally and remotely

0 votes

I’m trying to delete a branch locally as well remotely but its giving errors

$ 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 am I supposed to do?

Aug 17, 2018 in Git & GitHub by Hannah
• 14,090 points
85 views

2 answers to this question.

0 votes

Delete local branch

$ git branch -d branch_name
$ git branch -D branch_name

Delete remote branch

$ git push <remote_name> --delete <branch_name>

Then you should execute this on other machines

git fetch --all --prune

to propagate changes.

answered Aug 17, 2018 by Kalgi
• 39,150 points
0 votes

Deleting a remote branch:

git push origin --delete <branch>  # Git version 1.7.0 or newer
git push origin :<branch>          # Git versions 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
answered Aug 20, 2018 by Nilesh
• 6,900 points

Related Questions In Git & GitHub

0 votes
1 answer

How to do a re-merge into another branch in git

Seems like you want to rebase your ...READ MORE

answered May 7, 2018 in Git & GitHub by DareDev
• 6,810 points
112 views
0 votes
1 answer
0 votes
1 answer

Configure Git and GitHub

In version control with Git, we deal ...READ MORE

answered Apr 26, 2018 in Git & GitHub by DragonLord999
• 8,380 points
19 views
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
110 views
0 votes
1 answer
0 votes
2 answers

difference between git remote and git clone

git remote add just creates an entry in ...READ MORE

answered Aug 7, 2018 in Git & GitHub by Kalgi
• 39,150 points
527 views
0 votes
1 answer

gerrit-cherry-pick:fatal: 'origin' does not appear to be a git repository

The user account making that command does ...READ MORE

answered Aug 13, 2018 in Git & GitHub by Kalgi
• 39,150 points
189 views