4

I want to create a blog using the Octopress blog framework, which is based on Jekyll, but the documentation just says to clone the github repository.

It feels a bit weird to have the whole framework history into my blog repository. I don't really care about keeping Octopress' history and I don't think that keeping it in the repository of my blog makes any sense.

Now, I'm far from being a git expert but I thought of these different solutions:

  • Remove the .git directory
  • Rebase all previous commits with my first commit
  • Move the octopress history in a separate branch

But all of these solutions seem to have inconvenients and I start wondering if there is an ideal solution. Removing the .git after doing the clone would solve that but it would prevent me from updating the framework later, or at least doing it easily (or maybe it would be?). I'm not sure of that but if I choose to rebase, when I'll pull octopress repo again, I'll recreate all the framework history in mine, having to rebase again (but this time I would have done commits myself, so I guess it would be harder). I'm not really sure that the third solution would help or even be relevant.

What would do you think would be the best solution to keep my blog repository "clean", ie with most of the commits related to the blog, not the framework it is using?

Uflex
  • 1,396
  • 1
  • 13
  • 32

3 Answers3

3

You can do a shallow clone:

git clone --depth 1

That gets just the most recent commit history and thus gives you the current working tree. You can still pull later commits into it but you don't start off with the full Jekyll/Octopress history.

Yawar
  • 11,272
  • 4
  • 48
  • 80
  • Oh, didn't know we could do shallow clones with git (I really need to read that pro git book), would it pull the entire history if I do a `git pull octopress master`? – Uflex Jun 03 '13 at 08:19
  • @Uflex nope, just the history since the last pull. – Yawar Jun 03 '13 at 12:05
2

Removing the .git directory works. To update the framework later, just add back the octopress remote:
git remote add octopress git://github.com/imathis/octopress.git

For people following the "getting started", when cloning the repo, do this:

git clone --depth 1 git://github.com/imathis/octopress.git octopress
cd octopress
rm -rf .git
git init
git add -A
git commit -m "COMMIT MESSAGE"

Then, before running rake setup_github_pages, do this to add the remotes back and rename the master branch to source:

git remote add octopress git://github.com/imathis/octopress.git
git remote add origin YOUR-REPO-URL
git config branch.master.remote origin
git branch -m master source

Then finish the deployment tutorial.

1

I suggest using git submodules. See GitSubmoduleTutorial

cforbish
  • 8,567
  • 3
  • 28
  • 32
  • 2
    What would you put into a submodule? As far as I understand the submodules, you have to have a subfolder pointing to another repo, would you put the source folder as a submodule? – Uflex Jun 02 '13 at 20:11