Reputation: 1681
I am trying to effectively check out only a directory and its contents (a specific wordpress theme directory) inside a larger git repo hosted on Github on a server. The server has existing WordPress directories in it, and I want to place the new theme directory from the repo into the proper directory on the server. I first tried the approach described in an accepted answer to a similar question. When I ran the below line,
[scapa]$ git fetch [email protected]:mrengy/new-urban-arts.git
I got an error of:
fatal: Not a git repository (or any parent up to mount parent ) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
So I ran:
[scapa]$ git init
Initialized empty Git repository in /home/newurbanarts/stage.newurbanarts.org/.git/
[scapa]$ git remote add origin [email protected]:mrengy/new-urban-arts.git
Now when I run (as per the accepted answer):
[scapa]$ git fetch origin master
[scapa]$ git checkout origin/master -- wp-content/themes/newurbanarts
I get:
error: pathspec 'wp-content/themes/newurbanarts' did not match any file(s) known to git.
What am I doing wrong, and how do I get around this?
Upvotes: 2
Views: 716
Reputation: 328
So after some back and forth in the comments, I think we've come to a solution here.
As it turns out, GIT does support the concept of checking out only subtrees of a given repository, through a process called 'sparse checkout' which you can find more information about here.
The concept is to initialize a new, clean git repository, add your remotes, turn on the setting 'core.sparsecheckout,' and finally to check out your folders.
Upvotes: 2