Skip to content

Instantly share code, notes, and snippets.

@mvuorre
Forked from stephenhardy/git-clearHistory
Last active June 1, 2019 14:26
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 mvuorre/5d8529e3e7f5df95e2fedccfcdda2894 to your computer and use it in GitHub Desktop.
Save mvuorre/5d8529e3e7f5df95e2fedccfcdda2894 to your computer and use it in GitHub Desktop.
Steps to clear out the history of a git/github repository
-- Delete .git folder from disk
rm -rf .git
-- recreate the repo from the current content only (note old .gitignore is preserved)
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repo ensuring you overwrite history
git remote add origin https://github.com/<username>/<reponame>.git
git push -u --force origin master
@mvuorre
Copy link
Author

mvuorre commented Mar 25, 2018

Small edit to make it work

@ajirdoank
Copy link

i got frustrated for couple hours and i found your post. Many thanks sir. Saved my day.

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