0

From help.github.com git push can be used in the following way to delete a remote branch:

git push  <REMOTENAME> :<BRANCHNAME>

(...) you're telling Git to push nothing into BRANCHNAME on REMOTENAME. Because of this, git push deletes the branch on the remote repository.

However from git-scm.com, this also deletes a remote branch:

git branch -d -r <REMOTENAME>/<BRANCHNAME>

Adding that:

The next fetch or pull will create [it] again unless you configure [it] not to.

So would it be preferable to use one of these methods in a particular situation, or do they basically end up doing the same thing?

(Bonus point for examples:)

Armfoot
  • 4,663
  • 5
  • 45
  • 60
  • Thanks @phd actually [one of the answers in the question you referenced](https://stackoverflow.com/a/23961231/1326147) explains that using `git branch -dr /` only deletes the *remote-tracking* branch and not the actual remote branch. – Armfoot Nov 18 '17 at 22:35
  • The answer also explains that manually deleting a remote branch through the github interface does not delete the *remote-tracking* branch in the local repo, requiring later a pruning or the `git branch -dr ...` method. So the fastest option seems to be the `git push :` method, deleting both *remote-tracking* and *remote* branches at the same time. I marked this question as a duplicate to redirect people to [that answer](https://stackoverflow.com/a/23961231/1326147). – Armfoot Nov 18 '17 at 23:13

0 Answers0