Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

How do I delete a Git branch locally and remotely?

Failed Attempts to Delete a 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.

How do I properly delete the remotes/origin/bugfix branch both locally and remotely?

Answer*

Draft saved
Draft discarded
Cancel
1
  • 22
    ⚠️ Use git branch -D carefully in a script, since it force-deletes a branch without checking it has been merged. Use -d to be safe. Commented Mar 13, 2017 at 14:05

AltStyle によって変換されたページ (->オリジナル) /