gitgithubgit-subtree

Do a subtree push to a directory within the gh-pages branch?


We can push a subtree (In this example to doc folder) to gh-pages like this:

git subtree push --prefix doc origin gh-pages

If we wanted the content of the doc folder to be pushed to an api folder under gh-pages is it possible to specify an api folder as part of the push?

Or do would need to move the content of the doc folder to doc/api and then push doc? That would have the same desired effect ...


Solution

  • move the content of the doc folder to doc/api and then push doc?

    Yes, that's the only way. git subtree push doesn't do any magic, it just splits (using git subtree split) a separate branch and does git push. As git push cannot push into a subdirectory then git subtree push cannot do either.