I committed in the past some wrong files to git. After that I excluded and ignored these files:
git rm --cached -r config.php
git reset config.php
echo "config.php" >> .gitignore
git update-index --assume-unchanged config.php
Now git commit works great. Changes in config.php are not committed.
But: If I stash the working directory for example to switch the branch, than config.php is restored from the local repos.
How can I use git stash
without changing ignored (and from index excluded) files?
I found a solution at https://help.github.com/articles/remove-sensitive-data:
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch config.php' \
--prune-empty --tag-name-filter cat -- --all
May be a reset
is necessary to exclude it from future commits:
git reset config.php
After all information of config.php are removed from local branches, I made a forced push to update remote repos:
git push origin master --force
Now, my stash area works fine.