Loading...
Content coming right up. Please wait a moment.
Content coming right up. Please wait a moment.
Some basic troubleshooting steps for when changes within your .gitignore file are not updating correctly.
.gitignore file?This may be related to Git caching, and you can fix it by clearing your cache.
WARNING: This will remove all files from your Git cache, so make sure to commit ALL changes you want to save first.
Once you've verified all changes are committed, run one of the following commands based on your needs.
Note: Make sure you're in the root of your git repository where you normally run git commands.
1git rm -r --cached .;
2git add .;
3git commit -m "BUG: git cache not updating .gitignore. Purged. Recreated cached index.";bashWhat's happening here?
git rm -r --cached .;, we're telling Git to clear the cache of tracked
files, then re-add all files to the cache, and then update the index.git-rm "The primary function of git rm is to remove tracked files from the Git index."-r "The -r option is shorthand for 'recursive'. When operating in recursive mode git rm will remove a target directory and all the contents of that directory."--cached "The cached option specifies that the removal should happen only on the staging index. Working directory files will be left alone."Source: git-rm | atlassian.com
When you don't want to purge your entire cache, you can remove a single file. Assuming the file is defined in the .gitignore, this will stop the file from being tracked by git.
1git rm --cached <FILE>;bashWhen a file is removed from .gitignore filters and is not being tracked, you can add it to the cache manually.
1git add -f <PATH/FILENAME>;
2git commit -m "Re-Adding ignored file by force";bash