I have a repo on GitHub called foo with the following branches:
- master
- gh-pages
I have a second repo on GitHub called <username>.github.com (a user repo) with the following branches:
- master
- source
I would like to use the code in foo->master in <username>.github.com->source and be able to merge in changes from foo->master when they occur.
What is the best means of achieving this?
You can just add
foo/masteras a remote, merge it in from time to time (do this in<username>.github.comrepo):You can set
origin/sourceas remote forsourceandorigin/masteras remote for master as normal.You can also use
git fetch --allto update all remotes, includingoriginandfoo.If you don’t change much in
source, then the merge will almost always be fast-forward.You might want to set a remote url for foo that is read-only.
This way you can’t push from
<username>.github.comby accident and if it’s a public repo, you won’t need authentication (or password for your ssh key) for the fetch.You can keep git from fetching the
gh-pagesbranch withYou just have to remember setting that when you expect any other branches than
masterto appear fromfooremote.A good explanation of the refspec is in the git book