I've added and committed a wrong folder. After fixing the .gitignore file, I need to remove those files from the repository, but I don't want those files to be deleted when I run git pull
on the server.
I've tried the --cached
flag as suggested here Remove a file from a Git repository without deleting it from the local filesystem
but it just doesn't work. I remove the file by rm --cached file
. I commit the fact that is deleted. But when I git pull
it removes that file from the server.
Updated Example: SF2 parameters file (should be ignored, as it differs from machine to machine)
app/config/parameters.yml
- a file that should be ignored in .gitignore- is accidentally pushed into the repository
- fix the .gitignore file
- i need to remove it from the repository, but when I perform
git pull
on the server the file should not be removed. - in this example it's very simple with just one file to manually backup on the server, git pull (the file is removed), restore the backup.
- but in my case there are a lot of different folders/files.
By server I mean a clone of the repository, not the repository itself. It's just another machine with the repository cloned
Updated Short Explanation:
Let's consider repo-server | local-machine | deploy-server
.. I want to remove via local-machine
some files from the repository (if another local-machine-2
git clone
the repository it doesn't get these files), BUT when I update the deploy-server
via git pull
I don't want those files to be removed from the deploy-server