Firedrill: Recreate Github (or any other central) repository from developers clones
git, github
Solution
Just create an empty repository and, from the fully updated clone, do:
git remote add new-origin url://to/new/origin
git push --tags new-origin refs/remotes/origin/*:refs/heads/*
Obviously, if the new origin is at the same url as the original one, you must be careful to not fetch from origin.
Problem
Say you have a scenario with a central master git repository, which developers and CI-engines clone from. I.e. very close to a traditional non-distributed version control system setup, with a central hub and a lot of nodes. This could be a cloud service like Github (Gitlab/Savannah/Azure etc), or a Synology with git server or another in-house setup. Now say that server was stolen or struck by lightning or any other thing that would result that the central repository was gone along with all its centralized backups. All you have left is the various clones, and by good fortune one of these was fully updated, so you create a blank git repository replacement server to be used as the future central repository and go to work on the clone. The fully updated clone knows of all the "remotes/origin" branches with "git branch -a", but does only have a single local branch. (This is what worries me - losing branch information). What would the steps be for reestablishing a new central git repository behaving in any way like the old one, branches and all?
Related problems
- What's the difference between git clone --mirror and git clone --bare
- What is a tracking branch?
- Having a hard time understanding git-fetch
- Change a Git remote HEAD to point to something besides master
- Git: Correct way to change Active Branch in a bare repository?
- gitosis vs gitolite?
- Delete branches listed by git branch -a
- Track all remote git branches as local branches