Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Untrack folder locally in git and push to production without deleting

Tags:

git

I have a folder images which used to be tracked and which i untracked using: git rm -r --cached images.

I also added images/ to my gitignore. However I am afraid that when I commit and pull on my production server, the images folder will be deleted. The reason is because the github app actually shows the files are deleted.

So how do I prevent locally deleted, then untracked and ignored files to not be deleted on the production server on git pull?

like image 307
Ortixx Avatar asked Sep 04 '14 12:09

Ortixx


People also ask

Does git rm remove local file?

By default, the git rm command deletes files both from the Git repository as well as the filesystem. Using the --cached flag, the actual file on disk will not be deleted.


1 Answers

With git rm --cached, the files are removed from git, though they're still in your local folder. So after you push, the files on sever will be deleted, and so do others' repository when they pull.

A better way is to use git update-index.

git update-index --assume-unchanged images/*

It should fulfill your requirement. The only problem is that if others' change these image files and push to git server, you will still get these changes when you pull.

like image 193
Landys Avatar answered Sep 21 '22 10:09

Landys