How to Fix gitignore not working in .gitignore file?

A gitignore file may not be working for multiple reasons,

  1. committed code to the repository before creating gitignore file
  2. file type of gitignore file
  3. naming of gitignore file

How to Fix gitignore not working in .gitignore file?

Below are some solutions to the gitignore now working issue in a .gitignore file:
  1. If the files/folder are already in the repository then you have to remove them.
  2. If your .gitignore file is saved in any other encoding then UTF-8 like UTF-16, change it to UTF-8. (windows)
  3. Make sure your file name is .gitignore. There are some cases where we just name file as gitignore or gitignore.al or gitignore.txt.

Fix 1: Add Files/Folder to Repository again:

git rm -r --cached .
git add .
git commit -m "fixed untracked files" 

Fix 2: Fix encoding of gitignore file

Fix 3: Fix naming and file format of gitignore file


References:

Post a Comment

Thank you for comment, I really appreciate your view.

–>