jhpratt
jhpratt

Reputation: 7120

Keep file in git but remove locally

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:

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

Upvotes: 0

Views: 82

Answers (1)

VonC
VonC

Reputation: 1325137

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

Upvotes: 2

Related Questions