3

I was trying to ignore the changes on composer.phar and composer.phar files from the staging area (local host). So I followed this post answer and did:

git rm --cached composer.lock 
git rm --cached composer.phar

and added:

/composer.lock 
/composer.phar

to .gitignore file. And all seemed to go as expected, as those files were still there, but they weren't followed.

But now, when I try to pull the changes from the server, these files are removed. I don't what to remove those files, just don't follow them. How could I come back or resolve this issue?

Community
  • 1
  • 1
Manolo
  • 24,020
  • 20
  • 85
  • 130

1 Answers1

3

Well yes, you deleted the file from the index. You first need to get it back. You can either revert the commit which did that with

git revert sha_key_of_commit_that_deleted_it

or if you are ok about changing history you just reset your branch to the point before the change with

git reset sha_key_of_the_commit_where_sky_was_blue

Then, what you want to do is this to stop the file from receiving any further changes but keeping it the way it is:

git update-index --assume-unchanged /composer.lock

Christoph
  • 26,519
  • 28
  • 95
  • 133
  • I changed more files in the same commit and I don't want to delete them. What about adding again those files by `git add -f composer.lock composer.phar` and then do `git update-index --assume-unchanged composer.lock composer.phar` and commit? – Manolo Mar 25 '14 at 08:41