tags:

views:

30

answers:

1

I have a file named "myfile.php" on my server and in my computer.
I want to remove myfile.php from git index in order to prevent changing myfile.php in server.I do this by adding the file to .gitignore and removing the file from index with "git rm --chached myfile.php"
Now when I run "git pull" it removes the file itself from working directory in server but I want to keep it on the server and just keeping it safe from changing. What's the problem?

A: 

If you accidentally added to the index a file you want to remove from the index (but not delete from git's history) then use:

git reset HEAD <file>

Also, you can note that when you execute git status, git will actually tell you this:

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   my_file
#
$
abyx