search

Home  >  Q&A  >  body text

git - I want to push the dist folder under the master branch to the gh-pages branch. Is there any simple way?

I think there is no need to branch master in build first and then copy the dist folder to the gh-pages branch and then submit it
How do you guys manage the gh-pages branch?

曾经蜡笔没有小新曾经蜡笔没有小新2840 days ago1066

reply all(3)I'll reply

  • PHPz

    PHPz2017-05-02 09:48:13

    Have you read the update notes recently posted on Github?

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


    Of course, if you really want to use gh-pages (or any other directory name), here is what I think is the simplest method:

    First step

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

    Step 2

    git subtree push --prefix dist origin gh-pages

    Done. Among them:

    dist 代表子树所在的目录名
    origin 是 remote name
    gh-pages is the target branch name

    reply
    0
  • 淡淡烟草味

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

    npm intall gh-pages

    reply
    0
  • PHP中文网

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

    gh-pages has been upgraded and it seems that a separate branch is no longer needed.

    In the past, I wrote a separate command for this thing.
    It looks like this:

    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));

    Which git函数是使用require('child_process').spawn is the encapsulated child process.

    reply
    0
  • Cancelreply