suchen

Heim  >  Fragen und Antworten  >  Hauptteil

git - 想把 master 分支下的 dist 文件夹推送到 gh-pages 分支 有什么简洁的方法吗?

我想应该不需要先在 master 分支 build 然后复制 dist 文件夹到 gh-pages 分支再提交吧
各位大佬是如何管理 gh-pages 分支呢?

曾经蜡笔没有小新曾经蜡笔没有小新2833 Tage vor1055

Antworte allen(3)Ich werde antworten

  • PHPz

    PHPz2017-05-02 09:48:13

    你看了最近 Github 发表的一篇更新说明么?

    https://github.com/blog/2228-...


    当然,如果你的确想用 gh-pages(或别的什么目录名)的话,以下是一种我认为最简单的方法:

    第一步

    /dist 目录需要被 git 记录,于是后面我们才可以用它作为子树(subtree),因此 /dist 不能被 .gitignore 规则排除

    第二步

    git subtree push --prefix dist origin gh-pages

    搞定。其中:

    dist 代表子树所在的目录名
    origin 是 remote name
    gh-pages 是目标分支名称

    Antwort
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-02 09:48:13

    npm intall gh-pages

    Antwort
    0
  • PHP中文网

    PHP中文网2017-05-02 09:48:13

    gh-pages已经升级了,貌似不再需要单独的分支了。

    我以前的话,是单独给这个东西写个命令。
    差不多长这样:

    const promises = [task1, task2, task3, task4].map((n) => new Promise(n));
    
    Promise.all(promises)
        .then(git('init'))
        .then(git('add', '-A'))
        .then(git('commit', '-m', 'update'))
        .then(git('push', '-u', url, 'master:' + branch, '--force'))
        .then(() => console.log('\n INFO: 文件上传完毕。'))
        .catch((err) => console.log('\n INFO: 发生错误,意外中止\n' + err));

    其中git函数是使用require('child_process').spawn封装的子进程。

    Antwort
    0
  • StornierenAntwort