4

I am using jekyll to publish a static site directly on gh-pages branch in Github. The issue I have is that every time I run

$ jekyll --no-auto /Users/khinester/Sites/tzm/

this overwrites the .git directory and I have to recreate this:

$ git init-db
$ git add remote ..
$ git add .
$ git commit -a -m 'message'
$ git branch gh-pages && git checkout gh-pages
etc..
$ git push -f github gh-pages

basically i have the master branch containing the files needed to generate the blog and gh-pages branch which displays the actual blog.

and also note that i have to force push this.

it will be nice to have also be able to version control the updates!

i have read the https://github.com/mojombo/jekyll/wiki/Deployment but this seems has more steps then what i do now.

is there a better way to do this or have i missing something.

4

3 回答 3

1

Jekyll 有一个名为keep_files. Jekyll 重建站点时,该数组中的所有内容都将保留。

这是添加的位置:https ://github.com/mojombo/jekyll/pull/630 。搜索这些问题keep_files将揭示更多它的黑魔法。

默认情况下会添加 .git 和 .svn 文件,keep_files因此这不再是问题。

于 2013-07-15T23:11:56.157 回答
0

我使用 Steven Penny 的脚本编写了这个脚本,它开箱即用的是项目页面,而不是用户页面。

#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR

SELF=`basename $0`
SOURCE_BRANCH="master"
DEST_BRANCH="gh-pages"
TMP_DIR="tmp"

git checkout $SOURCE_BRANCH
jekyll build -d $TMP_DIR
git checkout $DEST_BRANCH
# This will remove previous files, which we may not want (e.g. CNAME)
# git rm -qr .
cp -r $TMP_DIR/. .
# Delete this script from the output
rm ./$SELF
rm -r $TMP_DIR
git add -A
git commit -m "Published updates"
# May not want to push straight away
# git push origin master
git checkout $SOURCE_BRANCH
于 2013-05-28T01:31:27.377 回答
0

我使用以下 shell 脚本将 Hakyll 生成的站点(在 directory 中_site)提交到gh-pages分支。剧本:

  • 不需要您切换分支...只需从master您所在的任何分支运行脚本即可。
  • 使用主存储库;jekyll 破坏.git目录并不重要,因为......它不存在!
  • 如果什么都没有改变,什么都不做!
  • 识别新的、以前未跟踪的文件(即使现有文件没有更改)
  • 向分支添加新提交gh-pages,因此您无需强制推送。
  • 在提交消息中包含时间戳

代码如下;根据需要更新路径

export GIT_INDEX_FILE=$PWD/.git/index-deploy
export GIT_WORK_TREE=$PWD/_site
REF=refs/heads/gh-pages
git read-tree "$REF"
git add --all --intent-to-add
git diff --quiet && exit
git add --all
TREE=$(git write-tree)
COMMIT=$(git commit-tree "$TREE" -p "$REF" -m "snapshot $(date '+%y-%m-%d %H:%M')")
git update-ref "$REF" "$COMMIT"
于 2016-01-06T05:57:34.907 回答