2

I have been trying this with no success.

I have a git repository that contains 3 folders. Lets say:

Folder A Folder B Folder C

I want to be able to pull just the contents of folder B to a webserver for example.

I just want to somehow init a git repo on the www folder for example and do some magic and have the files in Folder B pulled to this particular folder.

Doing a sparse-checkout on folder B creates folder B in my www folder. I just need the contents of it.

Is this even posible with Git ?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Marius Ilie
  • 220
  • 2
  • 13
  • possible duplicate of [Is there any way to clone a git repository's sub-directory only?](http://stackoverflow.com/questions/600079/is-there-any-way-to-clone-a-git-repositorys-sub-directory-only) – Chris Maes May 26 '15 at 09:23

1 Answers1

2

You can try a sparse checkout in order to load only the folder B.

git init <repo>
cd <repo>
git remote add -f origin <url>
git config core.sparseCheckout true
echo "Folder/B/" >> .git/info/sparse-checkout
git pull origin master

See "Is there any way to clone a git repository's sub-directory only?"

Since a sparse checkout does create a folder, you need to checkout it somewhere else, and make sure www is symlinked to that folder.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Doing this creates the Folder B folder (ex www/Folder B/~files) I only want the contents of folder B to be pulled (www/~files). – Marius Ilie May 26 '15 at 09:26
  • 1
    @MariusIlie then checkout it somewhere else, and set www as a symlink to folder B – VonC May 26 '15 at 09:27