img
Will & Skill logotype
Nyheter

2020-03-24

Deleting your git commit history without removing repo on Github/Bitbucket

Fire up

If you do not have hundreds of commits already. You can follow the steps mentioned below.

WARNING: This should be used with care! It also removes the configuration of the repo.

Step 1

Remove all history

$ cd myrepo
$ rm -rf .git

Step 2

Init a new repo

$ git init
$ git add .
$ git commit -m "Removed history, due to sensitive data"

Step 3

Push to remote

$ git remote add origin github.com:yourhandle/yourrepo.git
$ git push -u --force origin master

Source: StackOverflow