为什么 Git 远程删除的分支又在另一天复活了?
Why is Git branch deleted on remote resurrected another day?
我重命名了一个本地分支,在远程删除了相同的名称,将新名称推送到远程并像这样设置跟踪:
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
我已经为 20 多个分支完成了此操作(通过脚本)并且没有出现任何错误。
贡献者 git fetch --prune
并更新了他们的本地分支(重命名并设置了新的跟踪分支)。
一天后(星期五),在没有推送任何新提交的情况下,旧的 origin/my_branch
重新出现 在与 origin/feature/my_branch
相同的提交 上。没有人可以通过使用旧的跟踪分支完成的新提交和推送。所以,我删除了 origin/my_branch
.
今天(周末过后)origin/my_branch
再次出现 在与 origin/feature/my_branch
相同的旧提交 (日期为星期四)上。
我不明白 Git(垃圾收集器)如何以及为什么可以恢复已删除的分支,但可能原因在于 Gitblit (处理我的远程管理)端?
没有任何意义,除非是以下其中一个负责
- 您团队中的其他人正在再次推动此分支
- 外部代码(挂钩、脚本、cron 等)正在创建此分支。
- 它是
Gitblit
中定义的默认分支,因此正在重新创建它
它们之间的共同点是某人(人或脚本)是 creating/pushing 此代码。
最有可能发生的是您团队中的其他人正在再次推动该分支。
至于 git 版本 <2,当您编写 git pull/push
而不指定远程或分支时,它将 pull/push
所有分支。它已在版本 2 上更新。
Git v2.0 发行说明
When "git push [$there]" does not say what to push, we have used the
traditional "matching" semantics so far (all your branches were sent
to the remote as long as there already are branches of the same name
over there). In Git 2.0, the default is now the "simple" semantics,
which pushes:
only the current branch to the branch with the same name, and only
when the current branch is set to integrate with that remote
branch, if you are pushing to the same remote as you fetch from; or
only the current branch to the branch with the same name, if you
are pushing to a remote that is not where you usually fetch from.
You can use the configuration variable "push.default" to change
this. If you are an old-timer who wants to keep using the
"matching" semantics, you can set the variable to "matching", for
example. Read the documentation for other possibilities.
我重命名了一个本地分支,在远程删除了相同的名称,将新名称推送到远程并像这样设置跟踪:
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
我已经为 20 多个分支完成了此操作(通过脚本)并且没有出现任何错误。
贡献者 git fetch --prune
并更新了他们的本地分支(重命名并设置了新的跟踪分支)。
一天后(星期五),在没有推送任何新提交的情况下,旧的 origin/my_branch
重新出现 在与 origin/feature/my_branch
相同的提交 上。没有人可以通过使用旧的跟踪分支完成的新提交和推送。所以,我删除了 origin/my_branch
.
今天(周末过后)origin/my_branch
再次出现 在与 origin/feature/my_branch
相同的旧提交 (日期为星期四)上。
我不明白 Git(垃圾收集器)如何以及为什么可以恢复已删除的分支,但可能原因在于 Gitblit (处理我的远程管理)端?
没有任何意义,除非是以下其中一个负责
- 您团队中的其他人正在再次推动此分支
- 外部代码(挂钩、脚本、cron 等)正在创建此分支。
- 它是
Gitblit
中定义的默认分支,因此正在重新创建它
它们之间的共同点是某人(人或脚本)是 creating/pushing 此代码。
最有可能发生的是您团队中的其他人正在再次推动该分支。
至于 git 版本 <2,当您编写 git pull/push
而不指定远程或分支时,它将 pull/push
所有分支。它已在版本 2 上更新。
Git v2.0 发行说明
When "git push [$there]" does not say what to push, we have used the traditional "matching" semantics so far (all your branches were sent to the remote as long as there already are branches of the same name over there). In Git 2.0, the default is now the "simple" semantics, which pushes:
only the current branch to the branch with the same name, and only when the current branch is set to integrate with that remote branch, if you are pushing to the same remote as you fetch from; or
only the current branch to the branch with the same name, if you are pushing to a remote that is not where you usually fetch from.
You can use the configuration variable "push.default" to change this. If you are an old-timer who wants to keep using the "matching" semantics, you can set the variable to "matching", for example. Read the documentation for other possibilities.