1

I accidentally indexed a config file that shouldn't be indexed in git.

To remove it, I added it to my .gitignore file and did :

git rm --cached myfile.conf

Now, when I checkout a previous commit (before the deletion) and that I come back to my previous HEAD, git remove myfile.conf from my local file system.

How to avoid this ?

Dorian Marchal
  • 635
  • 1
  • 8
  • 11

1 Answers1

0

Try to skip the file (git update-index):

git update-index --skip-worktree -- myfile.conf

That should be preserved during checkout as I mentioned here.

If that doesn't work, try the alternative:

git update-index --assume-unchanged -- myfile.conf
Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755