Reputation: 2195
Is it possible to pull from a remote repository but only selectively take files from that remote that I'm interested in? I don't want to simply pull down the entire branch.
Thanks.
Upvotes: 12
Views: 18770
Reputation: 44244
A "remote branch" is nothing more than a commit pointer and the affiliated pack data. Just git fetch <remote>
and then if you want to view diffs between files on the remote and your local, you can do so with:
git diff <local_branch> <remote>/<remote_branch> -- <file>
This would in many cases be, for example, git diff master origin/master -- <file>
. You could also see the commit differences with git log
:
git log <local_branch>..<remote>/<remote_branch> -- <file>
so... git log master..origin/master -- <file>
Finally if you just want to checkout a particular version of a file from the remote (this wouldn't be ideal; much better to merge the remote branch with git merge <remote>/<remote_branch>
or git pull
), use:
git checkout <remote>/<remote_branch> -- <file>
Upvotes: 19
Reputation: 301157
No you have to fetch the entire branch, but may choose to checkout specific files.
Upvotes: -1