Skip to content

Instantly share code, notes, and snippets.

@mikerodionov
Last active June 18, 2021 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikerodionov/a422dfbe2802fd544d05e552f13d5370 to your computer and use it in GitHub Desktop.
Save mikerodionov/a422dfbe2802fd544d05e552f13d5370 to your computer and use it in GitHub Desktop.
# Checkout repo which needs history clear up
# Assuming repo has default "main" name
git checkout --orphan latest_branch
# Once current state checked out to local folder add all files
git add -A
# Commit "the changes"
git commit -am "Repo clear up"
# Delete your original remote branch
git branch -D main
# Rename the current branch to main
git branch -m main
# Force update remote repository
git push -f origin main
# This will remove your old commit history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment