Git Pull Single File from Remote

I have searched this thing way too many times on google to not write a self-post on this for the future.

Often there is a need to pull only a single file on the server since rest of the changes are not ready to put on the server or production yet.

Here is how to pull a single file from git remote

git fetch
// git fetch 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
// git checkout / -- path/to/file will checkout the particular file from the downloaded changes (origin/master).

That’s it!

Livewire Component Library
Amazon Shopping

Site Footer