问题
GitHub has a Project Pages feature that pulls from the gh-pages branch of a repository. It's explained here: http://pages.github.com/
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
This causes each instance of git push
to push the Master branch of the repository into the gh-pages branch.
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.
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.
回答1:
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.
You can take these steps to create the 'gh-pages' branch from within the GitHub Mac App:
- 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
Take these steps to sync your changes from the Master branch into the gh-pages branch:
- 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
来源:https://stackoverflow.com/questions/9069165/can-i-make-the-gh-pages-branch-of-my-git-repository-a-mirror-of-the-master-branc