简体   繁体   English

我可以使git仓库的gh-pages分支成为Master分支的镜像吗?

[英]Can I make the gh-pages branch of my git repository a mirror of the Master branch?

GitHub has a Project Pages feature that pulls from the gh-pages branch of a repository. GitHub具有项目页面功能,可从存储库的gh-pages分支中提取。 It's explained here: http://pages.github.com/ 在这里说明: http : //pages.github.com/

I want the gh-pages branch to be an exact mirror of the Master branch. 我希望gh-pages分支完全是Master分支的镜像。 One way I found ( here on Stack Overflow) is to run: 我发现(单程这里对堆栈溢出)是运行:

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

This causes each instance of git push to push the Master branch of the repository into the gh-pages branch. 这导致git push每个实例将存储库的Master分支git push送到gh-pages分支。

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 . 这种解决方案的问题在于我使用的是GitHub Mac App,它没有使用严格的git push According to http://mac.github.com/help.html it does a git pull --rebase . 根据http://mac.github.com/help.html,它执行git pull --rebase Additionally, even when I select Push from the Repository menu, my git config line isn't adhered to. 另外,即使我从“存储库”菜单中选择“ Push ”,我的git config行也未遵守。

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. 因此,我想知道是否有一种方法与GitHub Mac App完全匹配,从而使gh-pages分支成为Master分支的精确镜像。

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. 为了创建gh-pages分支,您似乎不需要经历他们在http://pages.github.com/上列出的确切过程。 You can simply create a new branch named gh-pages from within the GitHub Mac App. 您可以在GitHub Mac App中简单地创建一个名为gh-pages的新分支。

They probably don't instruct people to do this because what I'm accomplishing here isn't a typical scenario. 他们可能不会指示人们这样做,因为我在这里完成的工作不是典型的情况。

You can take these steps to create the 'gh-pages' branch from within the GitHub Mac App: 您可以按照以下步骤从GitHub Mac App中创建“ gh-pages”分支:

  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' 点击您的Master分支上的+按钮以创建一个新分支-将其命名为“ gh-pages”
  3. Click the Publish button to push it to GitHub 单击Publish按钮将其推送到GitHub
  4. Use the bottom left menu to checkout the Master branch, if you're not working in the Master branch 如果您不在Master分支中,请使用左下方的菜单签出Master分支

Take these steps to sync your changes from the Master branch into the gh-pages branch: 采取以下步骤将您的更改从Master分支同步到gh-pages分支:

  1. Make changes in your Master branch 在您的Master分支中进行更改
  2. In the Changes view, enter the commit summary & click the Commit & Sync button to push to the Master branch 在“更改”视图中,输入提交摘要,然后单击“ Commit & Sync按钮以推送到“主”分支
  3. Switch to Branches view 切换到分支视图
  4. Click the Merge View button to display the Merge view 单击Merge View按钮以显示合并视图
  5. Drag the Master branch to the left slot & the gh-pages branch to the right slot 将Master分支拖到左侧插槽,将gh-pages分支拖到右侧插槽
  6. Click the Merge Branches button 单击Merge Branches按钮
  7. Use the bottom left menu to checkout the gh-pages branch 使用左下方的菜单签出gh-pages分支
  8. Click the Branch in Sync button to force a synchronization 单击“ Branch in Sync按钮以强制同步

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM