dailyhack
dailyhack copied to clipboard
Ignoring a previously committed file quickly
Files already tracked by Git are not effected by the .gitignore file.
If you want to ignore a file that you've committed in the past,
- Use
echowith>>(double redirection arrow) to append a relative file path to your.gitignoredirectly from the terminal. - Use
git rmwith the--cachedoption to delete the file from your remote repository, but keep it in your working directory as an ignored file. - Commit.
$ echo debug.log >> .gitignore
$ git rm --cached debug.log
rm 'debug.log'
$ git commit -m "Start ignoring debug.log"
Thanks, @sashadev-sky this is what we called cool hack.
Nice, thanks for sharing this!