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

768    Asked by ranjan_6399 in Data Science , Asked on Jul 8, 2021

The scenario:

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

The file is pushed to the remote origin master repository

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

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 voila. How git checkout single file?

 

I'll be glad for any help, thanks!

Answered by Ranjana Admin

It can be done in the deployed repository:

    $ git fetch

The git fetch command will download all the recent changes, but it will not put it in your current checked out code (working area).

    $ git checkout origin/master -- path/to/file

Then the checkout command will update the working tree with the particular file from the downloaded changes (origin/master).


Your Answer

Interviews

Parent Categories