How to permanently delete a file from Git repository?

I accidentally checked in a test file with credentials in the code. I'd like to remove it completely from the Git repository, so that all history of the file is gone. Can this be done?

1 answer

Have you tried using the command git-filter-branch? I think this is the one you're looking for.

Heh, I love git. My initial response was "No, that sounds completely wrong! I don't want to filter a branch!" But you are correct, that seems to be what I want. Only one problem - I don't know how I would run this command on the BitBucket repository. Shell access is not allowed via SSH, and when I do this on my local repository, it doesn't show up as a change to push to origin.

Just to update, I tried the steps here for "Option 1: Delete files by name":

Now all my history is gone. Yay!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

2,007 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you