Skip to content

Instantly share code, notes, and snippets.

@Fedec96
Last active February 7, 2022 11:08
Show Gist options
  • Save Fedec96/26b382be831c2e6e34fe2f5de7f72b8a to your computer and use it in GitHub Desktop.
Save Fedec96/26b382be831c2e6e34fe2f5de7f72b8a to your computer and use it in GitHub Desktop.
Reset the commit history for a repository
#!/bin/bash
# Make the current commit the only (initial) commit in the target repository.
git checkout --orphan newBranch
git add .
git commit -m "Initial commit"
git branch -D main
git branch -m main
git push -f origin main
git gc --aggressive --prune=all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment