I have renamed a local branch, deleted the same on remote, pushed the new name to remote and set the tracking like this:
git checkout my_branch
git branch -m my_branch feature/my_branch # rename
git push origin :my_branch # delete on remote
git push --set-upstream origin feature/my_branch # push and set tracking
I've done this for 20+ branches (via a script) and there were no errors.
Contributors did git fetch --prune
and had updated their local branches (renamed and set new tracking branch).
A day after (on Friday), without any new commit being pushed, the old origin/my_branch
reappeared on the same commit as the origin/feature/my_branch
. There was no new commit & push that someone could have done by using the old tracking branch. So, I have deleted origin/my_branch
.
Yet again today (after the weekend) the origin/my_branch
reappeared on the same old commit (dated to Thursday) as origin/feature/my_branch
is on.
I don't see how and why Git (garbage collector) could resurrect the deleted branch, but possibly the reason is at Gitblit (which handles my remote administration) side?
It doesn't make any sense unless one of the following is the responsible
Gitblit
so its being re-createdThe common between those all is that someone (person or script) is creating/pushing this code.
The most likely to happen is that Some else on your team is pushing this branch again.
As for git version <2 when you write
git pull/push
without specifying remote or branch it willpull/push
all your branches. It was updated on version 2.Git v2.0 Release Notes