ryanjdillon
ryanjdillon

Reputation: 18948

.gitignore fails to ignore files not previously cached

I have a .gitignore file (made with vim on linux) in my repository's directory witht the following contents:

# Data files
*.txt

When I add any *.txt file to this repository, in the same directory as the .gitignore, it lists it as un-tracked and becomes tracked when I do a git add .

What's the deal? This is the same for other repositories with other file types.

Update

Trying a file .gitignore (on the command line) showed that I had the correct line endings:

.gitignore: ASCII text

Trying a :set list (in vim) showed that I DID have trailing whitespace:

# Data files$
*.txt $

Upvotes: 3

Views: 114

Answers (1)

tamewhale
tamewhale

Reputation: 1051

Check for trailing whitespace after patterns as this can cause Git to ignore them.

Upvotes: 2

Related Questions