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.
Author by
MadPhysicist
A technologist, a musician, an artist and a scientist.
Updated on July 05, 2022Comments
-
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 almost 8 yearsYes, 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 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 over 3 yearsShould be updated to note that only works with public repos, and the OP does not specify public or private.