foresth foresth - 1 month ago 11
Git Question

Git: How to update/checkout a single file from remote origin master?

The scenario:


  1. I make some changes in a single file locally and run
    git add
    ,
    git commit
    and
    git push

  2. The file is pushed to the remote origin master repository

  3. I have another local repository that is deployed via Capistrano with the "remote_cache" method from that remote repository

  4. Now I don't want to deploy the whole application but just update/checkout that single file.



Please, is this somehow possible with git? I wasn't able to find anything that would work nor was I able to figure it out. With SVN I just did
svn up file
and viola.

I'll be glad for any help, thanks!

Answer

Git doesn't work on individual files. I'm not aware of the remote_cache setting so I can't comment on that. However, in git, you have to clone the entire repository, make a change to a file(s), commit it (this is a local operation) and then push the changes back.

In your setup, you should be able to simply pull the changes from the master repository (call it M) to your capistrano deployed repo(call it B). I don't see why you're having the problem. If B is substantially different and you don't want to mess it up, you can add M as a remote to B and then cherry-pick the specific commits you're interested in (i.e. the update to the file you're talking about) into B. Would that work for you?