Remove sensitive data · GitHub Help

Remove sensitive data · GitHub Help

Purge the file from your repository

Now that the password is changed, you want to remove the file from history and add it to the .gitignore to ensure it is not accidentally re-committed. For our examples, we’re going to remove Rakefile from the GitHub gem repository.

git clone

# Initialized empty Git repository in /Users/tekkub/tmp/github-gem/.git/

# remote: Counting objects: 1301, done.

# remote: Compressing objects: 100% (769/769), done.

# remote: Total 1301 (delta 724), reused 910 (delta 522)

# Receiving objects: 100% (1301/1301), 164.39 KiB, done.

# Resolving deltas: 100% (724/724), done.

cd github-gem

git filter-branch –force –index-filter \

‘git rm –cached –ignore-unmatch Rakefile’ \

–prune-empty –tag-name-filter cat — –all

# Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (266/266)

# Ref ‘refs/heads/master’ was rewritten

This command will run the entire history of every branch and tag, changing any commit that involved the file Rakefile, and any commits afterwards. Commits that are empty afterwards (because they only changed the Rakefile) are removed entirely. Note that you’ll need to specify the path to the file you want to remove, not just its filename.

via Remove sensitive data · GitHub Help.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s