html导出不同的分支

我有一个github仓库中的组织文件,并使用未来的项目页面。 将组织文件导出到html,以便在像这样的gh-pages使用;

  • master分支上编辑组织文件并提交
  • 将html导出到临时目录
  • 将分支改为gh-pages
  • 从临时目录复制文件并提交
  • 有没有这种export/change branch/copy周期直接导出到gh-pages分支的方法?


    您可以导出到存储库的第二个克隆(而检出gh-pages分支),而不是导出到临时目录。

    如果您想要一个更自动但更复杂的解决方案,则可以在导出文件后运行以下脚本:

    #!/bin/sh
    
    usage() {
        cat <<EOF
    Usage: $0 [options] [--] <path_to_exported_html_files>
    
    Arguments:
    
      -h, --help
        Display this usage message and exit.
    
      -b <branch>, --branch=<branch>, --branch <branch>
        Commit the files to the given branch.  If the branch doesn't
        exist, a new root (parentless) commit is created.
        Defaults to: ${DEFAULT_BRANCH}
    
      --
        Treat the remaining arguments as path names.  Useful if the path
        name might begin with '-'.
    
      <path_to_exported_html_files>
        Directory containing the html files exported by org-mode.  If the
        path begins with '-', it will be treated as an option unless it
        comes after the '--' option.
    EOF
    }
    
    DEFAULT_BRANCH=gh-pages
    
    # handy logging and error handling functions
    log() { printf '%sn' "$*"; }
    warn() { log "WARNING: $*" >&2; }
    error() { log "ERROR: $*" >&2; }
    fatal() { error "$*"; exit 1; }
    try() { "$@" || fatal "'$@' failed"; }
    usage_fatal() { error "$*"; usage >&2; exit 1; }
    
    # parse options
    BRANCH=${DEFAULT_BRANCH}
    while [ "$#" -gt 0 ]; do
        arg=$1
        # the quotes around the equals signs in the case patterns below
        # are to work around a bug in emacs' syntax parsing
        case $1 in
            -h|--help) usage; exit 0;;
            -b|--branch) shift; BRANCH=$1;;
            --branch'='*) BRANCH=${1#--branch=};;
            --) shift; break;;
            -*) usage_fatal "unknown option: '$1'";;
            *) break;; # reached the path
        esac
        shift || usage_fatal "option '${arg}' requires a value"
    done
    [ "$#" -gt 0 ] || usage_fatal "must specify a directory"
    dir=$1; shift
    dir=$(cd "${dir}" && pwd -P) 
        || fatal "unable to convert ${dir} to an absolute path"
    [ "$#" -eq 0 ] || usage_fatal "unknown option: $1"
    [ -d "${dir}" ] || usage_fatal "${dir} is not a directory"
    
    # sanity check:  make sure ${BRANCH} isn't currently checked out
    # (otherwise 'git status' will show modified files when this script is
    # done)
    CURRENT_BRANCH=$(try git symbolic-ref HEAD) || exit 1
    case ${CURRENT_BRANCH} in
        refs/heads/"${BRANCH}") fatal "${BRANCH} must not be checked out";;
    esac
    
    # set up git
    GIT_DIR=$(git rev-parse --git-dir) 
        || fatal "unable to locate .git directory"
    GIT_DIR=$(cd "${GIT_DIR}" && pwd -P) 
        || fatal "unable to convert git directory to an absolute path"
    GIT_INDEX_FILE=$(mktemp -u) 
        || fatal "unable to generate a temporary file name"
    export GIT_DIR
    export GIT_INDEX_FILE
    export GIT_WORK_TREE="${dir}"
    
    # stage the files
    try cd "${dir}"
    try git add -Af .
    
    # commit the files
    PARENT=$(git rev-parse --verify -q refs/heads/"${BRANCH}") 
        || warn "creating a new branch named ${BRANCH}"
    TREE=$(try git write-tree) || exit 1
    COMMIT_MESSAGE="Import files from ${dir}"
    COMMIT=$(
        printf '%sn' "${COMMIT_MESSAGE}" |
        try git commit-tree "${TREE}" ${PARENT:+-p "${PARENT}"}
    ) || exit 1
    
    # update the branch to point to the result
    try git update-ref refs/heads/"${BRANCH}" -m "commit: ${COMMIT_MESSAGE}" 
        "${COMMIT}"
    
    # clean up
    try rm -f "${GIT_INDEX_FILE}"
    
    log "committed ${COMMIT} to ${BRANCH}"
    

    我解决了使用git子模块的问题。 现在我可以将我的组织文件导出到master存储库下的文件夹中。 这个文件夹实际上是一个相同的存储库gh-pages分支的子模块。 您可以在存储库和页面中检查我的org-publish-project-alist 。 现在我的发展周期;

  • master编辑然后导出HTML
  • 添加,推入gh-pages目录
  • 添加,推master根目录
  • 首先,我加入gh-pages分支为告诉记者,在github上,然后加入gh-pages分支作为子模块:

    [slmn@uriel org-test](gh-pages)$ git checkout master
    [slmn@uriel org-test](master)$ git submodule add -b gh-pages git@github.com:selman/org-test.git gh-pages
    [slmn@uriel org-test](master)$ git commit -m "branch added as submodule"
    

    导出index.org作为html到gh-pages目录:

    [slmn@uriel org-test](master)$ cd gh-pages/
    [slmn@uriel gh-pages](gh-pages)$ git add .
    [slmn@uriel gh-pages](gh-pages)$ git commit -m "pages updated"
    [slmn@uriel gh-pages](gh-pages)$ git push
    

    已更改的子模块添加到master模块:

    [slmn@uriel gh-pages](gh-pages)$ cd ..
    [slmn@uriel org-test](master)$ git add .
    [slmn@uriel org-test](master)$ git commit -m "pages updated"
    [slmn@uriel org-test](master)$ git push
    
    链接地址: http://www.djcxy.com/p/58657.html

    上一篇: html export different branch

    下一篇: Why does my pyinstaller created executable require admin privileges?