Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: Pulling only certain files

I'm using the TortoiseGit client on Win XP. In a particular folder, I have 3 modified files, whose modifications I wish to trash. In other words, I want to check out the latest versions of these three files from the remote repository. Note that there is another modified file in the same directory that I wish to leave as is. How do I get the latest version of only these 3 files?

Thanks - Dave

like image 657
Dave Avatar asked Nov 04 '11 15:11

Dave


People also ask

Can I pull only one file from git?

Short Answergit checkout origin/master -- path/to/file // git checkout <local repo name (default is origin)>/<branch name> -- path/to/file will checkout the particular file from the downloaded changes (origin/master).

How do I pull a single file from a git repository?

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!


1 Answers

A checkout with pathnames does not affect HEAD:

git checkout origin/master -- file1 path/file2 path/file3

Assuming default upstream remote/branch names (e.g. after a git clone)

Note that the three named files will be overwritten without warning. Any uncommitted local changes to these named files will be lost.

like image 185
sehe Avatar answered Sep 28 '22 18:09

sehe