You added a file to `.gitignore`, but `git status` still shows it as modified.
BeginnerTroubleshootingLost Work, HEAD and History Problems
Answer
Likely causes → The file is already tracked. Ignore rules apply only to untracked files.
Diagnose →
git ls-files --error-unmatch path/to/file
git check-ignore -v path/to/file
Fix → git rm --cached path/to/file, commit, and the ignore rule takes over. For a whole folder, git rm -r --cached dir/.
Prevent → Write .gitignore before the first commit, using a template for your language.
More on Lost Work, HEAD and History Problems
`fatal: Unable to create '/repo/.git/index.lock': File exists.`Beginner`fatal: your current branch 'main' does not have any commits yet`Beginner`Author identity unknown *** Please tell me who you are.` and `fatal: unable to auto-detect email address`Beginner`fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.`BeginnerYour commits do not show on your GitHub profile contribution graph.Intermediate`fatal: 'main' is already checked out at '/home/dev/app-hotfix'`Intermediate