How To Delete Committed Files With Sensitive Data From GitHub Commit History

preview_player
Показать описание
How to remove sensitive data from your GitHub repositories commit history. Deleting commits containing sensitive files is simple you can hide commits from your GitHub commit history with these simple instructions presented in the video.

00:00 Removing sensitive file from repository
00:28 Removing sensitive data from commit history

Commands: (MAKE SURE TO BE IN GIT BASH, OTHERWISE WILL NOT WORK)
git ls-files -i --exclude-from=.gitignore | xargs git rm --cached

git filter-branch --force --index-filter "git rm --cached --ignore-unmatch filename" --prune-empty --tag-name-filter cat -- --all

For example, removing .env files:
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch *.env" --prune-empty --tag-name-filter cat -- --all

git push origin --force --all

git push origin --force --tags

Socials:

{ZTF} William
#github #commithistory #deletecommit
Рекомендации по теме
Комментарии
Автор

nice, had the same prob with .env. thanks

YoannBuzenet
Автор

This is exactly what I was looking for

maximilianhagelstam
Автор

why does it keep telling me bad revision "rm", I double checked the spaces and everything.

ekkogaming