How to clone just the contents of a GitHub repository

Don’t laugh. I’m a complete Git noob. I needed to clone a WordPress project locally and repo was just the wp-content directory of the site. If I cloned this normally, it would install the entire repo to my machine, including the top-level root directory. But what I needed was just the contents of that directory […]

The post How to clone just the contents of a GitHub repository appeared first on Geoff Graham.


This content originally appeared on Geoff Graham and was authored by Geoff Graham

Don’t laugh. I’m a complete Git noob. I needed to clone a WordPress project locally and repo was just the wp-content directory of the site.

If I cloned this normally, it would install the entire repo to my machine, including the top-level root directory. But what I needed was just the contents of that directory so that I could use it with a standard WordPress installation.

The trick? Well, two approaches will do. The first is to cd into a completely empty /wp-content folder and clone the repo like this:

git clone https://github.com/some/repo.git .

That extra dot at the end. That’s all it takes! But if you find yourself getting an Terminal error that the directory isn’t empty, make sure you check for hidden files, like the classic ol’ DS_Store.

If that approach won’t do, it just takes a couple more steps:

git init
git remote add origin https://github.com/some/repo.git 
git pull origin master

Either of those approaches will clone just the contents of the repo rather than packaging them up into a root directory.

The post How to clone just the contents of a GitHub repository appeared first on Geoff Graham.


This content originally appeared on Geoff Graham and was authored by Geoff Graham


Print Share Comment Cite Upload Translate Updates
APA

Geoff Graham | Sciencx (2020-08-26T00:44:37+00:00) How to clone just the contents of a GitHub repository. Retrieved from https://www.scien.cx/2020/08/26/how-to-clone-just-the-contents-of-a-github-repository/

MLA
" » How to clone just the contents of a GitHub repository." Geoff Graham | Sciencx - Wednesday August 26, 2020, https://www.scien.cx/2020/08/26/how-to-clone-just-the-contents-of-a-github-repository/
HARVARD
Geoff Graham | Sciencx Wednesday August 26, 2020 » How to clone just the contents of a GitHub repository., viewed ,<https://www.scien.cx/2020/08/26/how-to-clone-just-the-contents-of-a-github-repository/>
VANCOUVER
Geoff Graham | Sciencx - » How to clone just the contents of a GitHub repository. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2020/08/26/how-to-clone-just-the-contents-of-a-github-repository/
CHICAGO
" » How to clone just the contents of a GitHub repository." Geoff Graham | Sciencx - Accessed . https://www.scien.cx/2020/08/26/how-to-clone-just-the-contents-of-a-github-repository/
IEEE
" » How to clone just the contents of a GitHub repository." Geoff Graham | Sciencx [Online]. Available: https://www.scien.cx/2020/08/26/how-to-clone-just-the-contents-of-a-github-repository/. [Accessed: ]
rf:citation
» How to clone just the contents of a GitHub repository | Geoff Graham | Sciencx | https://www.scien.cx/2020/08/26/how-to-clone-just-the-contents-of-a-github-repository/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.