-
-
Save rokibhasansagar/e9d3634084ec52583b25eeea122fa43f to your computer and use it in GitHub Desktop.
Bash script to remove all revisions from github or gist repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# By Zibri (2019) | |
# Modified by @rokibhasansagar | |
# | |
# Usage: gitclean git-repo-url | |
# | |
gitclean () | |
{ | |
git clone "$1" workDir && { | |
cd workDir/ | |
for BR in $(git branch | tr " " "\n" | grep -v '*') | |
do | |
echo "working on branch $BR" | |
git checkout $BR | |
git checkout --orphan cross | |
git add -A | |
git commit -m "Initial Commit" && { | |
git branch -D $BR | |
git branch -m $BR | |
git push -f origin $BR | |
git gc --aggressive --prune=all | |
} | |
done | |
} | |
cd $currDir | |
rm -rf workDir | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment