I have a git repository (with a github remote).
Then, I deleted the repository in github.
I want to recreate the git repository in github with full history (i.e. branching, commit and merging history).
How do I achieve it?
I had tried creating a new repository via web UI, cloning it, copying files one by one but it is too timeconsuming.
(i'm going to use git.example.com here instead of GitLab, as there is nothing specific to GitLab, except probably the possibility to create a a git repository via the webinterface; but these days, there are plenty of different providers with the same functionality)
create a new git repository via the webinterface, e.g. https://git.example.com/bfg/frobnozzel.git
create a local bare clone of your (local) repository (in this example closing into /tmp/new-frobnozzel.git:
git clone --bare /path/to/local/repository /tmp/new-frobnozzel.git
in the newly created bare-clone, change the remote to the new github repository:
cd /tmp/new-frobnozzel.git
git remote set-url origin [email protected]:bfg/frobnozzel.git
push your entire repository to the new remote:
cd /tmp/new-frobnozzel.git
git push --mirror origin
(optionally) switch your working repository to use the newly created remote repository as the main upstream, use:
cd /path/to/local/repository
git remote set-url origin [email protected]:bfg/frobnozzel.git
you might want to do an initial synch just to be sure that everything is working (git pull)
Btw, there's also some Github documentation that covers this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With