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
You can have many branches in your repository, but only one of these will be "checked out" as the working-tree so that you can work on it and make changes. git worktree adds the concept of additional working trees. This means you can have two (or more) branches checked-out at once.
There is no hard limit on the number of branches, tags, remote-tracking names, and other references. (All of Git's name-to-hash-ID map entries are refs or references: branch names are just refs whose full name starts with refs/heads/ ). These are not always stored in separate files.
Git offers a feature referred to as a worktree, and what it does is allow you to have multiple branches running at the same time. It does this by creating a new directory for you with a copy of your git repository that is synced between the two directories where they are stored.
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 <[email protected]>
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With