Cloning a Single File from Github Repo

26,225

Rather than clone, perhaps you can simply download the file.

Assuming the repository is public, you can download a single file like this:

wget https://raw.githubusercontent.com/jquery/jquery/master/src/ajax.js

To get the url, navigate to the file in GitHub, and choose the "raw" view.

Note that this will only work with public repos.

Share:
26,225
MadPhysicist
Author by

MadPhysicist

A technologist, a musician, an artist and a scientist.

Updated on July 05, 2022

Comments

  • MadPhysicist
    MadPhysicist almost 2 years

    Is it possible to clone a single file from a remote repository with Git? For instance, I am looking to copy someone else's .htaccess file into my own project. I do not need their entire repository, just this one file.

  • MadPhysicist
    MadPhysicist almost 8 years
    Yes, I have done just that. However, I am still wondering if Git allows for such operation to be done. It would be convenient. Can wget copy directories as well?
  • Jonathan.Brink
    Jonathan.Brink almost 8 years
    @MadPhysicist Yes, it's possible. See stackoverflow.com/questions/2466735/… . I was suggesting that perhaps a tool like wget or curl may be an easier option
  • shellscape
    shellscape over 3 years
    Should be updated to note that only works with public repos, and the OP does not specify public or private.