5

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!

Mr Mikkél
  • 2,577
  • 4
  • 34
  • 52
  • 1
    It does seem like a flaw in the Git philosophy, but I don't believe there's any way to do this. You can certainly remove a file from the repository without removing it from your working directory (`git rm --cached`), but whenever people do a pull, that file will get deleted, as you know. You might be out of luck.... – Ethan Brown Aug 24 '12 at 00:53
  • 1
    Try http://stackoverflow.com/questions/1143796/git-remove-a-file-from-the-repository-without-deleting-it-from-the-local-filesy?rq=1 or http://stackoverflow.com/questions/3318043/mark-a-file-in-the-git-repo-as-temporarily-ignored?rq=1 – ellotheth Aug 24 '12 at 00:56
  • 1
    Send emails to your folks and tell them to backup that file before pulling (cough...) And install pre-receive hook (http://criticallog.thornet.net/2011/06/02/running-php-linter-before-pushing-changes-to-a-git-repository/ ) to prevent such thing from happending again... – Penghe Geng Aug 24 '12 at 02:16

1 Answers1

2

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.

Douglas Lise
  • 1,466
  • 1
  • 20
  • 46