Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get file out of git repo and git ignore it without deleting it from filesystem

Tags:

git

So, a config file somehow made its way into our git repo that we don't want there. But we do want it on our individual systems.

Is there a way to get the file out of the repo without causing the file to get deleted from individual repos when our team members do a pull?

Many thanks!

like image 586
Mr Mikkél Avatar asked Nov 04 '22 17:11

Mr Mikkél


1 Answers

You will need to remove it from repository (not working tree) using

git rm --cached

and tell your coworkers to do a backup in the first time they sync (pull) their repositories, because git will delete it.
Otherwise, even the file being present on .gitignore, git will always detect changes when the file does part of the repository.

like image 112
Douglas Lise Avatar answered Nov 07 '22 21:11

Douglas Lise