我可以使我的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:
- 转到存储库的分支视图
- 单击
+
按钮在您的主分支上创建一个新分支 - 命名为'gh-pages' - 点击
发布
按钮将其推送到GitHub - 如果您不在Master分支中使用左下角的菜单检出Master分支
- Go to the Branches view of your repository
- Click the
+
button on your Master branch to create a new branch - name this 'gh-pages' - Click the
Publish
button to push it to GitHub - 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:
- 在您的主分支
- 在Changes视图中,输入提交摘要&点击
提交&同步
按钮以推送到主分支 - 切换到分支视图
- 单击
合并查看
按钮以显示合并视图 - 将主分支拖到左侧槽&点击
合并分支
按钮 - 使用gh-pages分支点击底部左侧菜单签出gh-pages分支
- 单击
同步分支
按钮强制同步
- Make changes in your Master branch
- In the Changes view, enter the commit summary & click the
Commit & Sync
button to push to the Master branch - Switch to Branches view
- Click the
Merge View
button to display the Merge view - Drag the Master branch to the left slot & the gh-pages branch to the right slot
- Click the
Merge Branches
button - Use the bottom left menu to checkout the gh-pages branch
- Click the
Branch in Sync
button to force a synchronization