Is it possible to have a GitHub repo with two branches that contain different directories on my local machine?

git, github, jekyll

Solution

It seems that all you want is to have a development branch and a master branch which will contain a mirror of the content of some folder, say _site.

Let's do this! Okay. I assume you have a repository with a development branch which contains all staff and `_site` folder you want to "export".

Lets create a commit which contains just the content of the `_site` folder.

`echo 'Fill with a meaningful description' | git commit-tree development^{tree}:_site` creates a commit and outputs its id. It was `47651a42...`. It will be different on your machine.

Note that `development^{tree}:_site` is a revision (sha1 sum) of the tree which corresponds to the `_site` folder in the root of the last commit on the `development` branch.

And now make master branch point to this commit: `git update-ref refs/heads/master 47651a42`

Now `git log master` show the following on my machine

commit 47651a42e6800f399c4352d0416f4ca96895f099
Author: Aleksandr Priymak <aleksandr.priymak@gmail.com>
Date:   Fri Jul 27 05:27:43 2012 +0400

    first commit

If you checkout this branch you get the content of the _site folder! That's simple. There is only one thing left. `47651a42` commit doesn't have any parents so you will need to add `-f` to your `git push` command to push updated master. The other way around is to actually specify the parent. To do this use this command

`echo 'Fill with a meaningful description' | git commit-tree dev^{tree}:_site -p $(cat .git/refs/heads/master)`

You can do this using the following one-liner

git update-ref refs/heads/master $(echo 'Add commit message here!' | git commit-tree dev^{tree}:_site -p $(cat .git/refs/heads/master))

Problem

I have a jekyll site that I would like to have hosted on GitHub. Since jekyll plugins aren't supported on GitHub I was wanting to have my mater branch only contain the files inside _site and make a development branch that has everything else in it. Would this be possible? If so how could I do it? I am not the best with git. thanks

Original source