Is it possible to pull just one file in Git? Is it possible to pull just one file in Git? git git

Is it possible to pull just one file in Git?


Here is a slightly easier method I just came up with when researching this:

git fetch {remote}git checkout FETCH_HEAD -- {file}


You can fetch and then check out only one file in this way:

git fetchgit checkout -m <revision> <yourfilepath>git add <yourfilepath>git commit

Regarding the git checkout command:

  • <revision> -- a branch name, i.e. origin/master
  • <yourfilepath> does not include the repository name (that you can get from clicking copy path button on a file page on GitHub), i.e. README.md


git checkout master -- myplugin.js

master = branch name

myplugin.js = file name