Last active
August 15, 2022 20:22
-
-
Save midwire/8d19032487721d23106e96389b8b54f3 to your computer and use it in GitHub Desktop.
[Git remove file from history] #git #shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example file is `.env` | |
# Remove the file from the disk | |
# Add the file path to .gitignore | |
echo ".env" >> .gitignore | |
# Permanently remove it from the git history | |
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD | |
# Force push | |
git push --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment