After creating and removing a few feature/hotfix/release branches I noted that some branches that should have been deleted kept returning in my list of Jenkins jobs.
So, nobody likes zombie jobs, right?
I started digging into the build-per-branch plugin. It uses "git ls-remote --heads
And behold: my branches that "git branch -r" would no longer show were still listed there!
I did delete the branches using "git branch -r -d
There is the other way for deleting remote branches: Pushing an empty repository to a remote branch with "git push origin :
But as it turns out the only surefire way to get rid of a remote repository seems to be to use "git push origin :
Update: I asked about this behavior ont the git mailing list:
Here is the response I got from the git mailing list:
Hi,I came across an issue with deleting remote branches: When deleting abranch using "git branch r d" the branch is deleted and no longer shown by "git branch r"."git ls-remote --heads" on the other hand still lists the ref for the lastbranch commit.If I delete the branch using "git push origin :" the branch is removed completely (i.e. git ls-remote no longer returns a ref).Is this a bug or is this behavior intentional? (I am currently using git1.7.12).
I think it clarifies the behavior. That thing that "git branch -r -d" deletes is only the local reference of the remote brach (the rempote tracking branch), i.e. the git branch command works fully locally.All of the above are expected and working as designed. Remotetracking branches are local _copies_ of what you have over there atthe remote repository. The latter is the authoritative version, andyou asked "ls-remote" to go over the network to view them.If you are trying to remove the branches you show to others andyourself who are observing that remote repository from your localworkstation, you can first "git push origin :" to remove it in the remote repository. You can run your next fetch with "--prune"to get rid of remotes/origin/, I think.
Only git push will really change *anything* on a remote repository.