Sometimes when I'm first developing I'll keep some secret stuff in my repos out of speed. At a later point in time I'll realize I need to remove it and any trace of it from the repositories history.
That's where these handy git commands come in.
1. First commit and outstanding code
2. To remove any changed files from the index (staging area), run:
git rm -r --cached
3. Don't be afraid, next run:
git add .
4. To commit it, run:
git commit -m ".gitignore is updated."
And voila!
Need to undo it?
git rm --cached {filename} git add {filename}