0

I'd like to remove a file locally while keeping it in future commits for git. .gitignore can't do this, as it only ignores changes (not deletions).

An example would (generally) be as follows:

  • add & commit file
  • ???
  • remove file, keeping in git

NB: This is not git rm --cached. What I want is the "opposite" of this.

jhpratt
  • 6,841
  • 16
  • 40
  • 50
  • Maybe a selective checkout (https://stackoverflow.com/questions/600079)? – david25272 Oct 31 '17 at 03:51
  • @david25272 I'm the maintainer of the repo. I just have an install file that I don't need, but still has to be in the repo. Hopefully that clears things up. (I'm not looking to clone anything) – jhpratt Oct 31 '17 at 03:52

1 Answers1

2

A simple rm (not git rm) should be enough.

But then, instruct the index that the file was not(!) deleted, with git update-index --assume-unchanged:

git update-index --assume-unchanged -- a/file
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250