git - I want to push the dist folder under the master branch to the gh-pages branch. Is there any simple way?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-02 09:46:13
0
3
1016

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?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(3)
PHPzhong

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

淡淡烟草味

npm intall gh-pages

Ty80

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template