DEV Community

Cover image for Use Fork Git Client to Remove Passwords from Git History
Jayson Rawlins
Jayson Rawlins

Posted on

Use Fork Git Client to Remove Passwords from Git History

What is Fork

Fork is a git client that runs your git commands for you inside of an interface. Similar to other products like GitHub Desktop abd GitKraken.

Why I like Fork

Fork UI provides a great deal of flexibility when setting up custom commands. The interface is decent and provides quick and easy GUI for all your Git needs.

However, being able to setup your client to run various commands on the repo is very handy.

Currently I have my JetBrain's products plus the ability to scan for secrets using nosey parker. All very very handy. I even use AICommit2 from time to time with a click of a button.

Meat and Potatoes

Using fork to delete a file out of git history.

1.) Create a Custom Command

2.) Call the custom command 'Remove Selected File from History'

Target needs to be File visible in file context menu

Git Security

3.) Select Bash Command

Add the following Script:

git filter-branch --force --index-filter "git rm --cached --ignore-unmatch '${file}'" --prune-empty --tag-name-filter cat -- --all && git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d && git reflog expire --expire=now --all && git gc --prune=now --aggressive
Enter fullscreen mode Exit fullscreen mode

Now you can simply right click on the offending file and remove its entire history (remember to ignore the file so it doesn't get committed again).

Top comments (0)