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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.