Saturday, May 5, 2012

checkout only one file using git

First clone the repo with the following command below,
git clone -n git://path/to/the_repo.git --depth 1

The -n option suppresses the default checkout of all files, and the --depth 1 option, which means it only gets the most recent revision of each file
Then check out just the file you want like so:
Then you can checkout the file that you wanted to get or save to your machine.

$> cd the_repo
$> git checkout HEAD name_of_file

No comments: