Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove files tracked by Git

Tags:

git

I'm working on cleaning up my local dev copy. I have a WordPress installation on the server, but I don't need any of the WP core files in the repo. I added wp-*.php to the local .gitignore, and removed some files using git rm --cached wp-*.php. I committed the changes, and pushed to the central repo.

On the production server, I went to pull the changes with git pull remote master and it deleted the wp-*.php files from the server.

What is the correct way to accomplish this, without a git pull deleting files from the production server.

like image 725
Poe Avatar asked Feb 18 '26 21:02

Poe


1 Answers

It will only remove them once (because you told Git to remove the files from its tracking). You can then manually add them back on the server side, and Git won't remove them again, because it will no longer be tracking them after the first removal.

like image 195
Amber Avatar answered Feb 21 '26 10:02

Amber