简体   繁体   中英

Recreating remote Github repository from local backup

Short version:

What is the correct way to restore a local Github backup, back onto Github, while preserving the commit history?

Long version:

So, a while back, I was working on a few private repositories on Github. I was going to take a break from working on them, so to save a few bucks (and avoid making the source public), I made sure my local branches were fully updated, and then deleted the repositories from Github. Now, I'm ready to restore those local files back to Github, this time as public instead of private. However, I'm running into problems actually getting the files back onto the server.

I've already created a bare repo with the same name on Github. Origin is set correctly, since the project has the same name (and URL) as before. It's a small personal project, so there is only one branch (master).

However, since my git status is up-to-date (preserved from when I made the backup), when I try to add -A / commit / push --all , nothing happens. Pulls from the new, blank remote repo don't seem to help.

I found a couple discussions on how to restore from local git backups, but they all assume that you're restoring onto your own server, and can run commands server-side. Obviously, this isn't the case with a Github-hosted repo.

Any help would be appreciated!

Did you create an initial commit to the github repo? Have you tried force with your push? If I am understanding your history correctly, then the local repo you have is not an ancestor of what exists on github presently, so you need to force the refs to update, which should fill in all the history for your github repo to match your local one.

   -f, --force
       Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to
       overwrite it. Also, when --force-with-lease option is used, the command refuses to update a remote ref
       whose current value does not match what is expected.

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