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
APA
Geoff Graham | Sciencx (2023-02-04T23:03:04+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 2023-02-04T23:03:04+00:00,<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 2023-02-04T23:03:04+00:00]. 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 2023-02-04T23:03:04+00:00. 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: 2023-02-04T23:03:04+00:00]
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/ | 2023-02-04T23:03:04+00:00
https://github.com/addpipe/simple-recorderjs-demo