.gitignore not ignoring filenames with spaces in them on `git status`

我怕爱的太早我们不能终老 提交于 2020-01-05 09:05:41

问题


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.



来源:https://stackoverflow.com/questions/19684620/gitignore-not-ignoring-filenames-with-spaces-in-them-on-git-status

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!