Search code examples
gitgitignore

.gitignore is ignored by Git


My .gitignore file seems to be being ignored by Git - could the .gitignore file be corrupt? Which file format, locale or culture does Git expect?

My .gitignore:

# This is a comment
debug.log
nbproject/

Output from git status:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       debug.log
#       nbproject/
nothing added to commit but untracked files present (use "git add" to track)

I would like debug.log and nbproject/ not to appear in the untracked files list.

Where should I start looking to fix this?


Solution

  • Fixed. OK, I created the .gitignore file in Notepad on Windows and it wasn't working. When I viewed the .gitignore file on Linux it looked like organised gibberish - perhaps Notepad had written out Unicode rather than ASCII or whatever 8-bit is.

    So I rewrote the file on my Linux box, and when I pulled it back into Windows it works fine! Hurrah!