0

This is my .gitignore file:

*.iml
*.conf

So I forced to add a file named settings.conf and now I want Git stop tracking changes on this file.

I tried with git rm --cached settings.conf but it removes the file from git repository. I want this file to stay on git repository but do not detect changes.

I also tried git update-index --assume-unchanged settings.conf and got : fatal: Unable to mark file settings.conf

Thanks in advance.

Gocht
  • 9,924
  • 3
  • 42
  • 81
  • Have check "git exclude" project/.git/info/exclude options, it might help you, however, if you place it on the exclude file it will be just in your machine. – Aderbal Farias Mar 29 '19 at 23:30
  • @RomainValeri I have tried that solution. I edited my question. – Gocht Mar 29 '19 at 23:30

1 Answers1

-1

You are looking for the command git update-index --assume-unchanged settings.conf

If you want to commit a change to the file, then you will need to toggle this setting using git update-index --no-assume-unchanged settings.conf, make your commit, and then repeat the first command.

Keith Hanlan
  • 768
  • 7
  • 13
  • Thanks, I edited my question. – Gocht Mar 29 '19 at 23:28
  • This is *not* what `assume-unchanged` is for. Git doesn't have any perfect way to do what OP wants, but `skip-worktree` is closer than `assume-unchanged`. In particular, `assume-unchanged` _does **not** prevent Git from seeing changes_. It's [actually the very opposite](https://public-inbox.org/git/xmqqy4z5go1y.fsf@gitster.dls.corp.google.com/): instead of saying, "hey, Git, I'm going to change this but you should just ignore it" it says "hey, Git, _I promise I won't change this file_". – ChrisGPT was on strike Mar 29 '19 at 23:36