Inazuma
Inazuma

Reputation: 178

Delete folder locally but keep remotely

I have a folder containing some code that will be required by anyone downloading my repository to their computer, but isn't needed by me. Let's call it foo.

I want to be able to delete foo from my local system, but not from the remote repository. I obviously cannot add it to .gitignore because it has already been tracked.

Is this possible with Git? If so, how can I do this? Any help would be much appreciated.

Upvotes: 2

Views: 154

Answers (1)

CodeWizard
CodeWizard

Reputation: 142174

Mark the files with assume unchanged and then delete them. From this point on git will ignore any changes made to those files.

https://git-scm.com/docs/git-update-index

--assume-unchanged

git update-index --assume-unchanged <path>

In case you need to print out list of files marked with the --assume-unchanged flag:

git ls-files -v|grep '^h'

enter image description here

Upvotes: 4

Related Questions