带上最新版本的主页 [英] Bring gh-pages up to date with the latest commit of master
问题描述
我将SourceTree与一个Github存储库结合使用,用于项目的版本控制。有一段时间,我一直在使用 master
来提交所有新的更改,但是现在我需要 gh-pages
分支以快进到 master
的最新提交,这样我就可以用生产中的页面更新实时页面(通常当重要更新完成了)。
我曾尝试重新定义,因为另一个SO帖子建议,但这使得问题更加严重,因为SourceTree让我手动选择我想要的更改以及重新分配花费了一些时间,特别是考虑了上次更新 gh-pages
之间的提交数量。在一个项目中成功重新绑定之后,我可以基本上同步 gh-pages
分支到任何我想要的所有内容的 master
之间的版本会自动提交(我无法在另一个存储库中重现相同的行为)。但是,我想要的是获取最后一次提交并覆盖所有文件。要做到这一点,我通常只是将整个文件夹复制到 master
分支到另一个位置,然后切换到 gh-pages
并手动覆盖所有文件。这是次优的,但对于大型项目来说可能会遇到问题。
因此,我想和需要的是自动完成此过程,无论是通过SourceTree还是通过脚本。
$ b TL; DR :我需要更新
gh-pages
到最新的 master
半自动提交,它将覆盖所有使用 master
中的文件而不用重新绑定,然后会推送他们到Github仓库。
然而,我想要的是获得最后的提交并覆盖所有文件。
您应该: 所以:
gh-pages
至 master
与 - 我们的
选项因此master实际上是未触及过的)。
gh-pages
(这意味着 gh-pages
快进至 master
并且变得相同)
git checkout master
git merge --ours gh-pages
git checkout gh- pages
git merge master
不要忘了,因为几天前,你不必再维护 gh-pages
分支。
I am using SourceTree in combination with a Github repository for version control for a project. For a while, I've been using master
to commit all new changes, but every now and then, I want the gh-pages
branch to fast-forward to the latest commit of master
, so that I can update the live page with the page I have in production (usually when a major update is finished).
I have tried rebasing, as another SO post suggested, but this made the problem even worse, as SourceTree had me manually choose what changes I wanted and the rebasing took a little while especially considering the amount of commits between the last update of gh-pages
. After successfully rebasing in one project, I could basically sync the gh-pages
branch to master
whenever I desired and all in-between versions would commit automatically (I could not reproduce the same behavior in another repository though). However, what I want is to get the last commit and overwrite all files. To do this, I usually just copy the whole folder while on master
branch to another location, then switch to gh-pages
and overwrite all files manually. This is sub-optimal, though and can get really problematic for larger projects.
So, what I want and need is to automate this procedure, either through SourceTree or via a script.
TL;DR: I need a way to update gh-pages
to the latest master
commit semi-automatically, which will overwrite all files with the ones in master
without rebasing and will then push them to the Github repository.
However, what I want is to get the last commit and overwrite all files.
You should:
- merge
gh-pages
tomaster
with the--ours
option (so master is actually untouched). - merge master to
gh-pages
(which meansgh-pages
fast-forwards tomaster
and becomes identical)
So:
git checkout master
git merge --ours gh-pages
git checkout gh-pages
git merge master
Don't forget though that since a few days ago, you don't have to maintain a gh-pages
branch anymore.
Simpler GitHub Pages publishing now allows to keep your page files in a subfolder of the same branch (no more gh-pages
needed):
这篇关于带上最新版本的主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!