1

i've tried what was suggested by a previous Stackoverflow question about how to ignore files: Ignore files that have already been committed to a Git repository

what was suggested:

git rm -r --cached .

the command I'm using:

git rm -r --cached application/config/config.php
//i only want to ignore this one file

Unfortunately, when I do git add. and then git commit my config.php is deleted from the repository and not just ignored.

I have a .gitignore file in my root directory and it contains the following list item:

application/config/config.php

might someone be able to help me understand why this config.php file is being deleted and just not being ignored?

here's what my git status shows:

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   .gitignore
#   modified:   application/config/config.php
#
no changes added to commit (use "git add" and/or "git commit -a")

thank you,

tim

Community
  • 1
  • 1
tim peterson
  • 23,653
  • 59
  • 177
  • 299

1 Answers1

3

It's being removed from the repository because you removed it. git rm is to remove the file and the --cached keeps it in your working directory.

You can do git update-index --assume-unchanged <filename> if you want to make it so it just never notices changes to a file, but leaves the old version in your repository. Further reading here: http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

Dan Ray
  • 21,623
  • 6
  • 63
  • 87
  • Hi Dan, that worked perfectly! I had a suspicion that `rm` wasn't the right command but didn't know about `git update-index...`. thanks! – tim peterson Apr 02 '12 at 14:57