Search code examples
gitgit-subtree

git-subtree checkout specific folder under other name


Hi I'm trying to setup a git-repo with two upstreams.

  • upstream-jointswp: (https://github.com/JeremyEnglert/JointsWP/)

    • The entire root-folder / goes to my repo at root /. (no problem)
  • upstream-woocommerce: (https://github.com/woothemes/woocommerce)

    • The subdir of this repo /templates should go under /woocommerce in my repo.
    • I was able to achive that the /templates goes as only folder/tree in my repo by using a sparseCheckout.
    • I try to use git-subtree to keep track of the commits.

When I use git-subtree. How do I checkout the stuff at /templates from my upstream to /woocommerce in my repo?

If my question isn't as straigth forward as I hope, plz give me a sign ;)


Solution

  • You should combine the split and add.

    So, you clone the project you want part of and then create a branch in it which will contain the templates/. I.e.

    git subtree --prefix=templates/ split -b templates_only
    

    Then you could use the branch from another repo:

    git subtree --prefix=woocommerce/ add ../woocommerce_clone/.git templates_only