0

I'm looking for the equivalent of svn export in git. But I actually want to export only one subdir. My structure looks like this:

/db
/html
/tools
...

I want to export only the /html dir in the repo, from given branch (let's say master) to some directory on the fs but without the internal .git dirs and omitting the files under .gitignore files. Ideally something like:

cd my_repo_dir
git export master/html/* /var/www/my_website_docroot

Can I do this and how?

ddinchev
  • 33,683
  • 28
  • 88
  • 133
  • 1
    http://stackoverflow.com/questions/4479960/git-checkout-to-a-specific-folder – nif Jul 07 '13 at 13:33
  • Thanks man, I will mark to close as duplicate! – ddinchev Jul 07 '13 at 13:39
  • There's also http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export. Also, as an option, you could always just export the entire repo, then delete everything you don't need. –  Jul 07 '13 at 20:16

1 Answers1

0
git checkout-index -f --prefix=/path/to/folder/ html/*
Rajat Singhal
  • 11,234
  • 5
  • 38
  • 56
  • This says "not in cache" for each subdir in `html/*` – ddinchev Jul 07 '13 at 13:48
  • It's a low level command, so it doesn't have a recursive option to deal with subdirectories. You would have to find all files in all subdirectories yourself and pass it to the command, e.g. `find html/ -type f | git checkout-index -f --prefix=/path/to/folder/ --stdin` – nif Jul 07 '13 at 13:58
  • @Veseliq, that would happen if git does not recognize the html dir..add and commit all the stuff then try – Rajat Singhal Jul 07 '13 at 15:19