Pergunta

I'm using Git Flow for my project, and have completed the git flow feature finish step that merged my feature branch into my develop branch.

I then performed git push to GitHub, but on GitHub I still see the feature branch as well as develop.

When I run git branch locally, I only see develop and master, which is what I'd expect.

How can I remove the branch from GitHub? I could cope with this one, but if this happens for every feature I'll end up with a massive list of old branches.

Many thanks in advance.

Foi útil?

Solução

Assuming the origin remote refers to your GitHub respository, you can delete the merged branch with:

git push origin :name-of-now-merged-branch

To explain that syntax further, when you do:

git push origin some-branch

... the some-branch parameter is actually a "refspec" which defines a mapping between a source name and a destination name, usually of the form <source-name>:<destination-name>. If there's no : in the refspec, it assumes that you mean some-branch:some-branch. The way to say "I just want to delete the remote branch" is to miss out the <source-name> completely, just ending up with : followed by the remote branch name.

Outras dicas

Check which remote branches are available

git branch -r

Then you can delete the remote branch with:

git push origin :branchname

To delete the branch local

git branch -d branchname

Edit:

http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html

As per this answer, if you do git push --all --prune, it will automatically remove all those merged branches without you having to go in manually and removing each one.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top