【问题标题】:synchronize git branch with master, selectively有选择地将 git 分支与 master 同步
【发布时间】:2013-07-07 06:24:21
【问题描述】:

我知道如何"synchronize" two branches (即每次更新 master 时都会更新 gh-pages 分支)。

我想要的是仅将 master 的某个目录同步到 gh-pages 分支。明确地说,这就是我想要实现的目标:

主人:

+-- some
|
+-- file
|
+-- here
|
+-- dist/
    |
    +-- some_other
    |
    +-- dist_file

gh 页面:

+-- some_other
|
+-- dist_file

换句话说,我希望在每次推送 master 时将 gh-pages 更新为 master 的 dist/ 目录。

可行吗?

【问题讨论】:

    标签: git github git-push git-config github-pages


    【解决方案1】:

    自己构建提交很容易:

    git commit-tree -p gh-pages -m "" master:dist \
    | xargs git update-ref refs/heads/gh-pages
    

    自动化只是个人喜好问题。最简单的方法是编写一个脚本并运行它。 Hooks 是审查你对 repo 所做的事情的入站工具;推动未经测试的 repo 更改并不是 git 真正设置为自动化的东西。我记得 github 根本不做钩子,所以如果你想在推送的东西上接收钩子,只需创建一个代理 repo 并让钩子进行同步并转发推送。

    【讨论】:

    • 不,你说你已经知道如何进行自动化,所以我省略了。
    • 我知道把push = +refs/heads/master:refs/heads/gh-pages push = +refs/heads/master:refs/heads/master放在.git/config里面会同步两个分支,真不知道你的方法能不能用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-12
    • 2013-11-14
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多