marchello
marchello

Reputation: 2136

Jekyll deployment with git

I have a Jekyll site with this folder structure:

jekyll_site
  _source
    file1 in source
    file2 in source
    etc...
  _deploy
    file1 in deploy
    file2 in deploy
    etc...

I have a git repo initialized in jekyll_site and I have two branches master and source. I want the source branch to only track the _source folder, and master to only track the _deploy folder. Also, I want to push them to a remote repository but make master branch appear as (in the remote repo):

master branch
  file1 in deploy
  file2 in deploy

Rather than:

master branch
  _deploy
    file1 in deploy
    file2 in deploy

So I want to shift the whole thing one level up. Suppose I could create another repo inside deploy just to make it root and push them separately? But maybe it's possible with one repo as well. Sorry if I overlooked something very obvious, I'm very tired (and very n00b with git).

Upvotes: 1

Views: 313

Answers (1)

Alan W. Smith
Alan W. Smith

Reputation: 25445

There are a few different things going on here.

  • Git isn't designed to have one directory managed on one branch with another directory maintained in a second branch. To manage two directories separately in the way you describe, two Git repos are needed. One repository for jekyll_site/_source and the second for jekyll_site/_deploy.

  • Using two Git repos takes care of moving your "_deploy" files up one level. Since the repository will be created at jekyll_site/_deploy, file will deploy to the root.

  • If you decide that you still want to use a single repository, don't fight against Git. That is, don't try to use different branches to separately manage the _source and _deploy directories. Just create one repo at the jekyll_site level. With this approach, you'll want to use something in addition to Git for your deployment. Write a simple script the moves the files from _deploy to wherever they need to end up.

  • Don't try to put one Git repository inside another one. Bad things will happen. (There is a way to do "Submodules" but that's not something you want to mess around with until you have more experience with Git.)

Upvotes: 1

Related Questions