既然我创建了 git 中心页面,如何修改我的 git 工作流程?

How to modify my git workflow now that I created github pages?

我有一个本地存储库,我每天都在使用它。通常,在一天的工作之后,我在本地提交并通过以下方式将所有内容推送到 github 存储库:

git add --all
git status // to check which changes are to be commited 
git commit -m "Some changes I've made"
git push origin master

最近,我通过在线创建工具点击离开,为我的在线存储库创建了一个 git 中心页面。现在我的项目有一个漂亮的页面,还有一个新的分支(称为 gh-pages)在我的在线存储库上(但是——到目前为止——当然不在我的本地存储库上)。

我的问题是:如果我想在我的计算机上本地编辑此页面并保持两个存储库同步(本地存储库和 github 存储库同步),我该怎么做?我应该如何修改我的 git 工作流程?

提前致谢。

您只需在 mastergh-pagesgit checkout 之间来回切换。更多详情如下。

您的原始工作流程(从上方):

git add --all
git status // to check which changes are to be commited 
git commit -m "Some changes I've made"
git push origin master

现在当你想在你的 GH 页面上工作时:

git fetch origin    # Only needed first time
git checkout gh-pages
# Make changes to your GH-pages files (your master branch files won't be available w/o switching back to master)
git add .    # or specific specific files to add
git commit -m "Commit message for GH-pages"
git push origin gh-pages

当您想回去处理 master、develop 等分支项目时,只需查看即可:

git checkout master

可以在 https://help.github.com/articles/creating-pages-with-the-automatic-generator/ 的底部找到此信息。

手动创建gh-pages孤儿分支的过程稍微复杂一些:https://help.github.com/articles/creating-project-pages-manually/

当然,如果您不是唯一一个处理该存储库的人,或者您在多台计算机上这样做,请确保在需要时 fetch/mergepull