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?
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 namegh-pages
is the target branch name
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.