简体   繁体   中英

How do I migrate a local git repository to github?

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 (ie 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.

  1. create a new github repository via the webinterface, eg https://github.com/bfg/frobnozzel.git

  2. 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 
  3. in the newly created bare-close, change the remote to the new github repository:

     cd /tmp/new-frobnozzel.git git remote set-url origin git@github.com:bfg/frobnozzel.git 
  4. push your entire repository to the new remote:

     cd /tmp/new-frobnozzel.git git push --mirror origin 

Btw, there's also some Github documentation that covers this .

The answer is simple: create a new repository on github (with the same name) and push the local repo to the remote(which should be correct)

Make sure that you push anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM