# 1. Remove .env from the current commit
git rm --cached .env
# 2. Add .env to .gitignore
echo ".env" >> .gitignore
git add .gitignore
git commit -m "Add .env to .gitignore"
# 3. Rewrite history to remove .env from all commits
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch .env' \
--prune-empty --tag-name-filter cat -- --all
# 4. Clean up repository
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now --aggressive
# 5. Force-push cleaned history to GitHub
git push --force --all
git push --force --tags
# 6. Inform collaborators to reset their local repositories
# (they can use the following commands)
git fetch --all
git reset --hard origin/main
-
Notifications
You must be signed in to change notification settings - Fork 0
AvasDream/i-pushed-credentials-for-my-companies-cloud-infra-and-now-all-our-customer-data-is-at-risk
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published