Fix Common Git Issues: .gitignore Not Working & Case-Sensitive Filename Tracking
Ever run into .gitignore not working or Git ignoring case-sensitive filename changes? This article explains why these issues happen and shows three easy fixes—clearing cache, enabling case tracking, and renaming files properly with Git commands.
When working on development, I often encountered two common Git issues:
- After updating
.gitignore, already tracked files couldn’t be ignored. - When renaming files with different letter cases, Git didn’t detect the change.
.gitignore not taking effect
The reason is that Git caches files that are already tracked. If certain files have been committed before, adding them to .gitignore won’t make any difference. To fix this, you can remove the local cache and commit again.
git rm -r --cached .
git add .
git commit -m "fix: update .gitignore"Here, the command git rm -r --cached . clears all cached files, but you can also specify individual file paths if needed.
Tracking case-sensitive file name changes in Git
By default, Git doesn’t track filename changes that only differ in letter case.
- One simple fix is to clear the cache and commit again.
git rm -r --cached .
git add .
git commit -m "fix: update file name"- Another approach is to configure Git to track case-sensitive changes.
git config --local core.ignorecase false- Finally, you can directly rename the file through Git itself.
git mv -f readme.md README.mdWritten by: Chia1104 CC BY-NC-SA 4.0