I have a file that once contained sensitive config information. I move that config info out into another file that isn't under version control. I want to keep the other file under version control, but I want to remove its history because one can easily browse the source on github and find the sensitive information in previous commits. What's the best way to do this? I'm only seeing how to remove the file itself from version control and clear its history.
A little new to git, so pardon the newbieness.
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-repo tool or the BFG Repo-Cleaner open source tool.
Steps to get to a clean commit history:understand rebase and replace pulling remote changes with rebase to remove merge commits on your working branch. use fast-forward or squash merging option when adding your changes to the target branch. use atomic commits — learn how to amend, squash or restructure your commits.
In Git, as with most version control systems, a repository retains a complete copy of the entire project throughout its lifetime. However, unlike most other VCSs, the Git repository provides not only a complete working copy of all the files in the repository but also a copy of the repository itself with which to work.
There are many ways to rewrite history with git. Use git commit --amend to change your latest log message. Use git commit --amend to make modifications to the most recent commit. Use git rebase to combine commits and modify history of a branch.
You might want to look at this article https://help.github.com/articles/remove-sensitive-data
Pretty much says this command
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch Rakefile' \
--prune-empty --tag-name-filter cat -- --all
Will remove the history of Rakefile
from git. However, they go ahead and add that file to their gitignore. You should probably skip that part since you want to keep the file in version control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With