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
  • 634
  • 1
  • 9
  • 14

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,262,500
  • 529
  • 4,410
  • 5,250