Hands-on task
Remove a secret from version control
In the repository /root/repo a secrets file secrets.env was committed by mistake. Take it out of version control without deleting the file itself from disk: stop tracking secrets.env (remove it from the index and record that with a commit) and add the line secrets.env to the .gitignore file so it no longer ends up in commits. Result: secrets.env stays on disk, but it's no longer in HEAD, and .gitignore contains secrets.env.
- git rm --cached
- index
- .gitignore
- stop tracking
- secrets