My Git Problems
A Git branch can be reset to exactly match the remote
Fetch the remote branch and set your branch to match it:
git fetch origin
git reset --hard origin/main
git clean -df
Remove env file from git forever
Accidentally pushed .env into git ?
Use this command :
git rm -r --cached .env
Once you run this, you will notice the .env has been removed from the repository.
But that is not the end of your problems. If someone looks at your Git history, he/she can still find the file and expose the secrets!
How to remove the Git History?
To remove every trace of the .env file ever being exposed, run the following command in your terminal.
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD