Skip to content

Instantly share code, notes, and snippets.

@lzkill
Last active January 19, 2023 11:25
Show Gist options
  • Save lzkill/8008518da2fbabc50c1fca7f33f2e45f to your computer and use it in GitHub Desktop.
Save lzkill/8008518da2fbabc50c1fca7f33f2e45f to your computer and use it in GitHub Desktop.
Clear git history
#!/bin/bash
default_branch=`basename $(git symbolic-ref --short refs/remotes/origin/HEAD)`
git checkout --orphan tmp
git add -A
git commit -m "first commit"
git branch -D $default_branch
git branch -m $default_branch
git push -f --set-upstream origin $default_branch
git gc --aggressive --prune=all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment