Skip to content

Instantly share code, notes, and snippets.

@ckunte
Last active January 4, 2016 11:39
Show Gist options
  • Save ckunte/8483a89f583b6c3f15b9 to your computer and use it in GitHub Desktop.
Save ckunte/8483a89f583b6c3f15b9 to your computer and use it in GitHub Desktop.
This script allows me to purge my git history. (Run from within the root of repo's folder.)
#!/usr/bin/env python
# encoding: utf-8
"""
ph.py -- purge (git) history
2015 ckunte
"""
import os
def main():
fullpath = os.getcwd()
foldername = os.path.basename(os.path.normpath(fullpath))
repo = "[email protected]:ckunte/" + foldername + ".git"
cmd1 = 'git reset --hard; rm -rf .git/; git init; git add .; git commit -m "first commit.";'
cmd2 = 'git remote add origin ' + repo + '; git push --force origin master;'
os.system(cmd1 + cmd2)
pass
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment