[英]Git how to rebuild lost central repository from cloned copies
We had a central Git repository on a separate server. 我们在一个单独的服务器上有一个中央Git存储库。 All the team members have cloned it to their local machines and did pull/push to that central repository. 所有团队成员都将其克隆到本地计算机,然后拉/推到该中央存储库。
Unfortunately, the machine with the central repo has crashed and is not recoverable. 不幸的是,具有中央仓库的机器已经崩溃并且无法恢复。
Now, how can we rebuild a central repo again using the cloned copies from developers' machines and how to sync the local changes from different cloned repos to this rebuilt central repo? 现在,我们如何使用开发人员机器中的克隆副本再次重建中央存储库,以及如何将来自不同克隆存储库的本地更改同步到此重建的中央存储库?
Thanks for your help. 谢谢你的帮助。
The central repo isn't anything special, so this is actually quite easy: 中央回购并不特别,所以这实际上非常简单:
Just initialize a new empty central repo. 只需初始化一个新的空中央回购。 If it has the same URL as the old one, your developers don't even have to add a new remote. 如果它具有与旧URL相同的URL,则开发人员甚至不必添加新的远程。
Then have one developer do a git push
. 然后让一个开发人员进行git push
。 This will cause all branches to be restored on central that have remote tracking enabled on that developer's machine. 这将导致在该开发人员的计算机上启用远程跟踪的中央恢复所有分支。
Everyone else can then pull and push again, as usual. 然后,其他人可以像往常一样再次拉动和推动。 Remote tracking branches that other developers have that aren't yet on central will be restored in this process. 其他开发人员尚未处于中心位置的远程跟踪分支将在此过程中恢复。
If somebody has a branch without remote tracking that should nonetheless be restored on central, that developer needs to git checkout
that branch and then git push origin HEAD
(assuming that origin is central). 如果某人有一个没有远程跟踪的分支,但仍然应该在中心恢复,那么开发人员需要git checkout
那个分支然后git push origin HEAD
(假设origin是中心)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.