我可以使我的git仓库的gh-pages分支成为Master分支的镜像吗? [英] Can I make the gh-pages branch of my git repository a mirror of the Master branch?

查看:139
本文介绍了我可以使我的git仓库的gh-pages分支成为Master分支的镜像吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GitHub有一个Project Pages功能,可以从存储库的gh-pages分支中获取。这里解释: http://pages.github.com/

GitHub has a Project Pages feature that pulls from the gh-pages branch of a repository. It's explained here: http://pages.github.com/

我希望gh-pages分支成为主分支的精确镜像。我发现的一种方式(此处在堆栈溢出)运行:

I want the gh-pages branch to be an exact mirror of the Master branch. One way I found (here on Stack Overflow) is to run:

git config --add remote.origin.push +refs/heads/master:refs/heads/gh-pages

这会导致每个 git push 将存储库的主分支推送到gh-pages分支。

This causes each instance of git push to push the Master branch of the repository into the gh-pages branch.

我对这个解决方案的麻烦是我使用GitHub Mac App,它不使用严格的 git push 。根据 http://mac.github.com/help.html ,它会执行 git pull --rebase 。另外,即使当我从Repository菜单中选择 Push 时,我的git配置行也不被遵守。

The trouble that I have with this solution is that I'm using the GitHub Mac App, which doesn't use a strict git push. According to http://mac.github.com/help.html it does a git pull --rebase. Additionally, even when I select Push from the Repository menu, my git config line isn't adhered to.

所以,我想知道是否有适合GitHub Mac App的方式来让gh-pages分支成为Master分支的精确镜像。

So, I'm wondering if there is a way that fits well with the GitHub Mac App to get the gh-pages branch be an exact mirror of the Master branch.

推荐答案

我经历了一堆我自己的测试。似乎您不需要经过他们在 http://pages.github上列出的确切流程。 com / 为了创建gh-pages分支。您可以在GitHub Mac App中简单地创建一个名为gh-pages的新分支。

I ran through a bunch of my own tests. It doesn't seem like you need to go through the exact process they've laid out at http://pages.github.com/ in order to create the gh-pages branch. You can simply create a new branch named gh-pages from within the GitHub Mac App.

他们可能不会指示人们这样做,因为我在这里完成的不是典型的场景。

They probably don't instruct people to do this because what I'm accomplishing here isn't a typical scenario.

您可以采取以下步骤在GitHub Mac App中创建'gh-pages'分支:

You can take these steps to create the 'gh-pages' branch from within the GitHub Mac App:


  1. 转到存储库的分支视图

  2. 单击 + 按钮在您的主分支上创建一个新分支 - 命名为'gh-pages'

  3. 点击发布按钮将其推送到GitHub

  4. 如果您不在Master分支中使用左下角的菜单检出Master分支

  1. Go to the Branches view of your repository
  2. Click the + button on your Master branch to create a new branch - name this 'gh-pages'
  3. Click the Publish button to push it to GitHub
  4. Use the bottom left menu to checkout the Master branch, if you're not working in the Master branch

执行以下步骤将您从Master分支所做的更改同步到gh-pages分支:

Take these steps to sync your changes from the Master branch into the gh-pages branch:


  1. 在您的主分支

  2. 在Changes视图中,输入提交摘要&点击提交&同步按钮以推送到主分支

  3. 切换到分支视图

  4. 单击合并查看按钮以显示合并视图

  5. 将主分支拖到左侧槽&点击合并分支按钮

  6. 使用gh-pages分支点击底部左侧菜单签出gh-pages分支

  7. 单击同步分支按钮强制同步

  1. Make changes in your Master branch
  2. In the Changes view, enter the commit summary & click the Commit & Sync button to push to the Master branch
  3. Switch to Branches view
  4. Click the Merge View button to display the Merge view
  5. Drag the Master branch to the left slot & the gh-pages branch to the right slot
  6. Click the Merge Branches button
  7. Use the bottom left menu to checkout the gh-pages branch
  8. Click the Branch in Sync button to force a synchronization

这篇关于我可以使我的git仓库的gh-pages分支成为Master分支的镜像吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆