Nuke GIT Repository History

Suppose you’ve just commited a private API key that should not be public. Or maybe you just wanna restart your repository, because you’ve just finished major surgery and wanna start fresh.

If you’d like to delete all GIT history, you’d need to:

1. Remove all history

[cc]rm -rf .git[/cc]

2. Reconstruct the Git repo with only the current content

[cc]git init
git add .
git commit -m “Initial commit”[/cc]

3. Push to GitHub.

[cc]git remote add origin
git push -u –force origin master[/cc]

Source here.

%d