Hello everybody. 2 weeks ago i commited config of my application. It is not very useful. How I can exclude the file from changings history?
You can
git rm myConfigFile
echo myConfigFile > .gitignore
git add .gitignore
git commit -m "from now on, no more myConfigFile"
The other extreme approach (dangerous especially if you have already pushed your repo to a remote one) would be to entirely remove that file from the history of said repo:
git filter-branch --index-filter 'git update-index --remove myConfigFile' HEAD
(to use with care, and with a backup first)
The question How do I remove sensitive files from git’s history has more on that sensitive topic.
The problems with this process are twofold:
1/ If your repo has already be cloned, you can never guarantee the confidential information will be really "gone" from every other repo.
2/ When others try pull down your latest changes after this, they'll get a message indicating that the the changes can't be applied because it's not a fast-forward. To fix this, they'll have to either delete their existing repository and re-clone it, or follow the instructions under "RECOVERING FROM UPSTREAM REBASE" in the git-rebase
manpage.
In both case, your confidential information will not be "quietly" replaced or erased...
cp my-config config.tmp
git rm my-config
git commit -m 'removed config'
mv config.tmp my-config
echo my-config >> .gitignore
git add .gitignore
git commit -m 'ignore config'
Sorry I explained my problem badly.
I want to remove the file from all commits tree because it contains my passwords.