added 1 character in body
Source Link
leoly
  • 7.5k
  • 5
  • 30
  • 29

Alternatively, instead of pruning your obsolete local remote-tracking branches through git fetch -p, you can avoid making the extra network operation by just manually removing the branch(es) with the --remoteremotes or -r flags:

Alternatively, instead of pruning your obsolete local remote-tracking branches through git fetch -p, you can avoid making the extra network operation by just manually removing the branch(es) with the --remote or -r flags:

Alternatively, instead of pruning your obsolete local remote-tracking branches through git fetch -p, you can avoid making the extra network operation by just manually removing the branch(es) with the --remotes or -r flags:

Used more standard formatting (we have italics and bold on this platform), etc.
Source Link
Peter Mortensen
  • 30k
  • 21
  • 99
  • 124

The Short Answers

The short answers

The Long Answer: there are 3 different branches to delete!

The long answer: there are three different branches to delete!

When you're dealing with deleting branches both locally and remotely, keep in mind that there are 3three different branches involved:

Visualization of 3 branchesVisualization of three branches

Additional Details

Additional details

If you didn't delete your remote branch X from the command line (like above), then your local reporepository will still contain (a now obsolete) remote-tracking branch origin/X. This can happen if you deleted a remote branch directly through GitHub's web interface, for example.

The Short Answers

The Long Answer: there are 3 different branches to delete!

When you're dealing with deleting branches both locally and remotely, keep in mind that there are 3 different branches involved:

Visualization of 3 branches

Additional Details

If you didn't delete your remote branch X from the command line (like above), then your local repo will still contain (a now obsolete) remote-tracking branch origin/X. This can happen if you deleted a remote branch directly through GitHub's web interface, for example.

The short answers

The long answer: there are three different branches to delete!

When you're dealing with deleting branches both locally and remotely, keep in mind that there are three different branches involved:

Visualization of three branches

Additional details

If you didn't delete your remote branch X from the command line (like above), then your local repository will still contain (a now obsolete) remote-tracking branch origin/X. This can happen if you deleted a remote branch directly through GitHub's web interface, for example.

minor change for clarity/explicitness, & spelling
Source Link
Gabriel Staples
  • 21k
  • 5
  • 130
  • 166
git branch --delete <branch>
git branch -d <branch> # Shorter version
git branch -D <branch> # Force -delete un-merged branches
git branch --delete --remotes <remote>/<branch>
git branch -dr <remote>/<branch> # Shorter

git fetch <remote> --prune # Delete multiple obsolete remote-tracking branches
git fetch <remote> -p      # Shorter
git branch --delete <branch>
git branch -d <branch> # Shorter version
git branch -D <branch> # Force delete un-merged branches
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
git branch --delete <branch>
git branch -d <branch> # Shorter version
git branch -D <branch> # Force-delete un-merged branches
git branch --delete --remotes <remote>/<branch>
git branch -dr <remote>/<branch> # Shorter

git fetch <remote> --prune # Delete multiple obsolete remote-tracking branches
git fetch <remote> -p      # Shorter
fix markdown abuse
Source Link
Loading
added 51 characters in body
Source Link
Loading
added a short version of flag
Source Link
YakovL
  • 6.3k
  • 11
  • 52
  • 82
Loading
HTTPS links and images
Source Link
Valentin Lorentz
  • 9.2k
  • 5
  • 45
  • 65
Loading
Changed documentation anchor text and formatting, because I hated the previous formatting.
Source Link
user456814
user456814
Loading
Add dash.
Source Link
user456814
user456814
Loading
Updated.
Source Link
user456814
user456814
Loading
Updated formatting.
Source Link
user456814
user456814
Loading
Updated diagrams.
Source Link
user456814
user456814
Loading
Removed more redundancy.
Source Link
user456814
user456814
Loading
Removed unnecessary redundant sections, clarified answer generally, improved formatting.
Source Link
user456814
user456814
Loading
Updated documentation links.
Source Link
user456814
user456814
Loading
Shortened commands.
Source Link
user456814
user456814
Loading
Updated branch names.
Source Link
user456814
user456814
Loading
Added "short answer" section for those people who don't want to bother reading a long explanation. Also removed link to top-voted answer because I don't copy it verbatim, and the long explanation of the link detracts from the clarity of my own answer.
Source Link
user456814
user456814
Loading
Updated header.
Source Link
user456814
user456814
Loading
Add pictures.
Source Link
user456814
user456814
Loading
Add picture.
Source Link
user456814
user456814
Loading
Updated formatting, clarified.
Source Link
user456814
user456814
Loading
Made it clearer that the alternative pruning method is only an option when the remote branch is already deleted.
Source Link
user456814
user456814
Loading
Added a tl;dr summar header section.
Source Link
user456814
user456814
Loading
Clarified why the original poster's original attempts to delete the remote branch didn't work.
Source Link
user456814
user456814
Loading