Question

We had a central Git repository on a separate server. 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.

Was it helpful?

Solution

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.

Then have one developer do a 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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top