Noitidart Noitidart -4 years ago 87
Git Question

Github, created new local repo for new work, want to push/merge to online

I was working on a online Github repo I created.

I had to go offline for a month, and during this time I thought to redo the repo from scratch. So I created a new local repo on my system using the Windows Github app. Screenshot at bottom.

I now have internet and want to push it to the my online repo. I already did a commit to delete all the files from the online repo. I now need to push my local to the online. Can I do this either with the github app for windows, or with git command line? I was hoping my timeline of commits can be retained.

Here is a screenshot of my windows github app in my local repo:


Answer Source

If you've made a commit that's deleted all files from your remote repository, and you've got a new local repository with a completely different commit history started from scratch, then why not just force push your new branch to the remote?

First backup your remote master.

git checkout -b oldmaster origin/master
git push origin oldmaster
git checkout master
git push -f origin master
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download