Skip to content

Instantly share code, notes, and snippets.

@CppHotReload
Last active June 13, 2020 19:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CppHotReload/ed7229b54060ba05c59ed7ece41af53b to your computer and use it in GitHub Desktop.
Save CppHotReload/ed7229b54060ba05c59ed7ece41af53b to your computer and use it in GitHub Desktop.
reset repository - 2020

From various authors, just what worked for me.

Safe Method creating an orphan branch

Check out to a temporary branch:

git checkout --orphan TEMP_BRANCH

Add all the files:

git add -A

Commit the changes:

git commit -am "Initial commit"

Delete the old branch:

git branch -D master

Rename the temporary branch to master:

git branch -m master

Finally, force update to our repository:

git push -f origin master This will not keep our old commits history around. But if this doesn't work, try the next method below.

Deleting .git and forcing

Clone the project, e.g. myproject is my project repository:

git clone https://github/heiswayi/myproject.git

Since all of the commits history are in the .git folder, we have to remove it:

cd myproject

And delete the .git folder:

git rm -rf .git

Now, re-initialize the repository:

git init git remote add origin https://github.com/heiswayi/myproject.git git remote -v

Add all the files and commit the changes:

git add --all git commit -am "Initial commit"

Force push update to the master branch of our project repository:

git push -f origin master NOTE: You might need to provide the credentials for your GitHub account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment