简体   繁体   English

Git如何从克隆副本重建丢失的中央存储库

[英]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.

相关问题 Git 远程重命名和克隆存储库的不同副本 - Git remote renaming and different copies of cloned repository 如何从中央远程存储库进行git提取? - How to git fetch from a central remote repository? 如何重命名GIT中央存储库 - How to rename GIT central repository 如何将克隆的git存储库与原始存储库合并 - how to merge cloned git repository with the original repository 如何从git存储库中删除文件,而不在克隆的存储库中删除它 - How to remove a file from a git repository, without deleting it in cloned repositories 如何确定最初克隆本地 Git 存储库的 URL - How to determine the URL that a local Git repository was originally cloned from 如何从 Git 的中央存储库更新特定文件夹/文件? - How to update particular folder/file from central repository in Git? 从github克隆了一个git仓库-我如何在我的账户中创建一个新的github仓库 - cloned a git repository from github - how do i create a new github repository into a repository into my account 如何从当前现有的本地git存储库中最佳设置“中央” git存储库? - How to best set up a “central” git repository from a current existing local git repository? 如何更改使用--bare克隆的git存储库以匹配使用--mirror克隆的一个存储库? - How to change a git repository cloned with --bare to match one cloned with --mirror?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM