A gitignore file may not be working for multiple reasons,
- committed code to the repository before creating gitignore file
- file type of gitignore file
- 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:
- If the files/folder are already in the repository then you have to remove them.
- If your .gitignore file is saved in any other encoding then UTF-8 like UTF-16, change it to UTF-8. (windows)
- 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
Post a Comment
Thank you for comment, I really appreciate your view.