Git映射目录到分支

问题描述:

我有资料库博客

I have repository blog:

blog
├─ master
│  └─ _site
│     └─ more folders
│
└─ gh-pages

我想将 master:_site / 映射到分支 gh-pages 。如何使用 git

I would like to map master:_site/ to the branch gh-pages. How would I do this using git?

我相信这是完全偏执:

#!/bin/sh
if ghpages=`git rev-parse -q --verify gh-pages`; then
        # there's already a branch, don't double-commit a tree
        committed=`git rev-parse -q --verify gh-pages^{tree}`
        current=`git rev-parse -q --verify master:_site`
        test x$current = x$committed && exit
fi
if commit=`git commit-tree ${ghpages:+-p $ghpages} -m 'updating gh-pages' master:_site`; then do
        git update-ref refs/heads/gh-pages $commit
fi

为了根据请求硬连接映射,把它放在 .git / hooks / post-commit chmod + x 它。

To hardwire the mapping as requested, put that in .git/hooks/post-commit and chmod +x it.