Restarting a github repo without history.

I have a project I`ve been working on in GitHub.  I have updated files.  I now have a large .git folder full of old (working) updates.  I would like to save 1Gb (size of .git folder) by starting again, but keep it on same Link to github.com?  How can I let GitHub know that Everything is OK, continue with same name in same folder, just dump all old history?

You can do that with a few git commands. Please back up your repo before doing this:

First create the new history:

git checkout --orphan new-master

Then create the first commit:

git commit

Then delete the old master branch and any other branches you want to delete:

git branch -D master

Now you can rename new-master to master:

git checkout -b master
git branch -d new-master

And now you can force push this new branch to GitHub to make GitHub forget the old history as well:

git push -u -f origin master
4 Likes