How do I download just 2 files from github using command line ?
Something in the lines of :
git fetch git://github.com/username/Project.git/file1
git fetch git://github.com/username/Project.git/file2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you go to the page and view the links provided by “raw” (in the top left corner, when viewing the file). You will see, that you can access it by:
Instead of
$changeset_hashyou can also provide a branch (e.g. master) or tag.You can retrieve the raw file using something like wget.
Accessing a single file directly from a .git-repository is not possible (as far as I know), because of how the data is stored.
edit: When you want to access a file from a private repo, you first have to create an access token with the appropriate permissions in your account settings. Instead of calling the url above you can then use github’s API to access the content of a file. Be sure to use the Accept-header for custom media types to get the raw data. This might look something like this:
The
-Owill save the contents in a local file with the same name as the remote file name. For easier use you can wrap it in a script. @Chris_Withers suggested an edit with a nice python snippet that unfortunately got rejected as to big of a change to the answer.