.gitignore not ignoring filenames with spaces in t

2019-07-28 21:26发布

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?

标签: git gitignore
2条回答
一夜七次
2楼-- · 2019-07-28 21:29

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.

查看更多
Lonely孤独者°
3楼-- · 2019-07-28 21:35

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)

查看更多
登录 后发表回答