.gitignore not ignoring filenames with spaces in t

2019-07-28 20:53发布

问题:

When I do a git status I get:

#       modified:   COM/config/Config/Edit Project Settings.lnk

But in my .gitignore I have:

*.lnk

What is going on here? Could it be a problem with whitespaces?

回答1:

The problem is not with the whitespaces.

I think the file is already tracked in your git repo, so you can remove it from the repo using the following:

git rm -r --cached "COM/config/Config/Edit Project Settings.lnk"
git commit -m "removed .lnk"

This won't delete the .lnk file, only untrack it locally (Though it will delete on other folks machines once this commit goes upstream)



回答2:

Ok so my problem actually was that the files where already in the repository, so adding the pattern to .gitignore did not prevent git from tracking changes on them.

What was needed was

git update-index --assume-unchanged <file>

Now their changes are not tracked anymore.

Else as ansh0l pointed out git handles spaces perfectly fine.



标签: git gitignore