Skip to content

Instantly share code, notes, and snippets.

@waylan
waylan / creating-project-pages-using-git-subtree.md
Last active March 8, 2022 09:30
Use subtree to merge commits from a project subdir (i.e., 'docs/') to gh-pages branch.

Creatings Project Pages using git-subtree

Many projects maintain their documentation within a subfolder of their repository (for example docs/). That way, as new features are added or existing features are modified, the documentation can be updated in the same commit. The git-subtree command can be an effective tool to merge those changes from the documentation subdirectory of your project to the root of the gh-pages branch.

Setup

According to the author of git-subtree, the command is included with git 1.7.11 and higher. However, it's in the "contrib" subtree for now, so it's not installed by default. Search for "git-subtree" in your system's package manager and install the package if it exists. If not, or if you are using an older version of git, the easiest way is to install git-subtree from the author's repo.

$ git clone https://github.com/apenwarr/git-subtree.git