$ bash <(curl -s https://gist.githubusercontent.com/robertoentringer/c9e327479f012bafeaeaaf48d3966aaf/raw)
Last active
May 12, 2019 00:16
-
-
Save robertoentringer/c9e327479f012bafeaeaaf48d3966aaf to your computer and use it in GitHub Desktop.
Bash script to clear out the history of a git/github 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 | |
function gitclear() { | |
repo=`git config --get remote.origin.url` | |
[[ -z "$repo" ]] && { echo "Git remote origin url not found in: `pwd`"; return; } | |
info="All commits (local and remote) will be lost!"$'\n' | |
question="Are you sure you wish to continue? [N/y] " | |
read -p "$info$question" -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
rm -fr .git | |
git init | |
git add -A | |
git commit -m "Initial commit" | |
git remote add origin $repo | |
git push -u --force origin master | |
fi | |
} | |
gitclear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment