Delete a file or directory completely from git repository

Committed a large file which is not needed. Committed a file containing password. Git rm does not remove the file completely form history. Either the size of .git becomes unnecessarily large or sensitive information is still in the repository history.git-filter-branch is your friend. You should have a look at its manual page. I wrote a python script to purge a file or directory from repo history. It can be found here. Pass the filename as -f filename and directory as -d dirname to this script. It will do the rest. It only works on master branch. On other branches, you have to push yourself.Make sure to provide full path of file or directory. I am not sure if it would work on regex.


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