tre*_*der 4 git version-control gerrit
我开始使用(被迫)Gerrit,当我的项目已经进行中时,所以我将"一切"推向Gerrit,使用git push orgin -all.前段时间,我注意到我还推了一些额外的分支,在开始使用Gerrit之前合并到master中并且已经在本地删除了:
$ git branch --all
* master
remotes/oberon/master
remotes/origin/96-fix-key-editors-references
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)
我试图删除那个远程分支,即ususal方式(git push origin :remotes/origin/96-fix-key-editors-references),但我被Gerrit拒绝,声称我没有选项Push权限Force Push,这是完成此任务所必需的.
所以,我去Project > Branches了Gerrit的web UI,标记了那个分支并且能够通过Delete按钮删除它(有趣的是:我可以在UI中做一些事情,我通过SSH禁止了什么?).
我认为案件已经结束,直到我再次执行git branch --all,才发现,Git仍然将分支报告remotes/origin/96-fix-key-editors-references为现有(结果与上面完全相同).
我再次使用git push origin :remotes/origin/96-fix-key-editors-references,只是为了满足我的好奇心,现在会发生什么,我收到了错误信息error: unable to delete '96-fix-key-editors-references': remote ref does not exist.
所以,两个问题,但实际上是一个:
Gerrit如何从Web UI中删除分支,而不是在同一时间从Git的repo中删除它?
远程分支如何在列表中列出并在同一时间内不可删除(不存在)?
我是Git的新手,甚至是Gerrit的新手,因为我可能会遗漏一些过时的东西.对不起!
Ash*_*son 12
您在输出中看到的分支名称git branch --all是远程跟踪分支 ; 它是本地存储库中一个特殊的只读分支,每次获取时都会与远程分支同步.默认情况下,即使分支从远程分离,git也不会删除它们,如果你真的不想删除它们,你就有机会恢复它们.
此命令将删除远程中不再存在的任何过时的远程跟踪分支:
git fetch origin --prune
Run Code Online (Sandbox Code Playgroud)