我可以合并/同步一个分支的子文件夹到另一个git的根目录吗? [英] Can I merge/sync a sub-folder from one branch to the root of another in git?
本文介绍了我可以合并/同步一个分支的子文件夹到另一个git的根目录吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在master中拥有一个/ doc文件夹,并轻松地将它合并/同步到gh-pages分支的根目录。什么是最简单的方法来做到这一点?
I want to have a /doc folder in master and easily merge/sync it to the root of a gh-pages branch. What is the easiest way to do this?
推荐答案
#!/bin/sh
# if there's a docbranch tree and it matches master:doc,
# then get out now, there's nothing to do:
current=`git rev-parse -q --verify docbranch:` \
&& test $current = "`git rev-parse -q --verify master:doc`" \
&& exit 0
# update the docbranch ref to a new commit ...
git update-ref refs/heads/docbranch $(
# ... which has master:doc, parented on docbranch if that exists yet
git commit-tree ${current:+-p docbranch} -m "updating" master:doc
)
你可以使用它作为你的post-commit钩子,并且每次你提交时都使用它 chmod + x
如果 master
doc
目录发生了变化,它会将其提交到 docbranch的头部
。
You can use that as your post-commit hook and chmod +x
it, every time you commit anything, if the master
doc
directory has changed it will commit it to the head of docbranch
.
由于树已经提交,这个增加的唯一东西是(〜200字节)提交对象本身。
Since the tree's already committed, the only thing this adds is the (~200 byte) commit object itself.
这篇关于我可以合并/同步一个分支的子文件夹到另一个git的根目录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文