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
?
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With