0

I have two machines: dev and live. on the live server I updated a file (a config file). and on the dev server I added few new files.

Now when I do the following on the live server:

git pull origin master

I get a message that Í have some uncommited files and I can't do a pull.

But I don't want to update the repository with that file!

when I do git stash or git reset hard (so I can use git pull) the file on the live server is changed to the original file from the dev server. I already added the file to gitignore but it gets updated from the dev server anyway after I do the pull. :(

What should I do so the file on the live server wont be updated by the file from dev?

MilMike
  • 12,571
  • 15
  • 65
  • 82

1 Answers1

1

If you want to always ignore the file, you can try:

git update-index --assume-unchanged path/to/config/file

This tells git to ignore changes to that file. Keep in mind, it can still be overwritten if someone else changes the file in the remote repository and you pull the changes.

It sounds like you need to (as you mention) ignore the file from the repository altogether. After you've added the file to your .gitignore, try running the following:

git rm -r --cached .

Followed by:

git add --all

Then committing the changes. This will delete the file from the git repository (It will remain on the filesystem, however will no longer be tracked by git).

rmorrin
  • 2,305
  • 1
  • 15
  • 18