2

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?

Shahbaz
  • 46,337
  • 19
  • 116
  • 182
RedX
  • 14,749
  • 1
  • 53
  • 76

2 Answers2

9

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)

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
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.

RedX
  • 14,749
  • 1
  • 53
  • 76
  • 1
    This works only till you don't do a pull. AFAIK, you have to set this every time after doing a pull – Anshul Goyal Oct 30 '13 at 14:22
  • This is really not a good solution. If you want that file in the repository, then you would also want the changes to that file. If you don't want it in the repository, then simply remove it as ansh0l says. If you want to keep an older version, you can restore it's older version. – Shahbaz Oct 30 '13 at 14:25
  • Think about config files or link files (aka shortcuts) under windows. Since shortcuts update their targets i don't want them to show modifications as it will change for every user. Sometimes some things are defined by people who don't know better and they are in a position where you can't argue with them but have to live with their decisions. – RedX Oct 30 '13 at 15:28
  • `--assume-unchanged` is risky, if you do a checkout that would modify that file (because you switched to a branch that doesn't have it, for example) the checkout will simply fail (even `--force`d!), until you `--no-assume-unchanged` that file – Simon Buchan Dec 05 '13 at 04:18