-1

I created a test repo locally on my PC and added some text to it. Then created a test branch, merged it with main, deleted the test branch and pushed everything with git push. But when I check my GitHub copy of that repo the test branch still exists! Why?

  • 1
    Does this answer your question? [Remove old remote branches from Git](https://stackoverflow.com/questions/17470691/remove-old-remote-branches-from-git) – sleske Jan 26 '22 at 07:24
  • 1
    Note that in Git terminology, a "remote branch" is a branch in a "remote" (a remote repo such as GitHub). – sleske Jan 26 '22 at 07:25

1 Answers1

0

deleted the test branch and pushed everything with git push. But when I check my GitHub copy of that repo the test branch still exists! Why?

That is by design. If you delete a branch locally, this deletion will not be automatically propagated when pushing your repository to a remote repository. This is because in general, it is normal and expected for a remote repository to have (many) branches that you do not exist in your local repository.

If you want to delete a branch in a remote repository, you need to delete it explicitly. This is done with git push:

git push --delete origin name-of-branch-to-delete

where, "origin" is the name of the remote repository (which is "origin" by default), and name-of-branch-to-delete is, obviously, the name of the branch you want to delete. Note that this must be the name of the branch in the remote repository - you may have given the branch a different name in your local repository (though by default the names will be the same).

sleske
  • 81,358
  • 34
  • 189
  • 227