How to I push two branches to two separate GitHub remotes?
I have a project where the
data folder need to private (but tracked by VCS). So the entire
git repo on GitHub is private. The code, however, is quite useful to many people and so I’d like to keep that public.
Currently my repo has only a
dev. Once features in
dev are working, they get merged into
master. I’d like to create a
no_data branch and have that push to a public GitHub repo.
master should continue tracking the private repo. I already have a private GitHub repo for this (let’s call it
private_project). I can create a public repo called
project for the
- Why can't Bundler locate this gem?
- Is correct this interpretation about a git diff HEAD message?
- GitHub - How to revert changes to previous state
- Synced without committing changes and lost locally saved (Xcode and Github Desktop)
- Git/GitHub can't push to master
- How to fix “cannot be resolved to branch” on git push?
a) How do I set this up so each branch track a separate repo?
b) Since the only thing different between the two branches is that the public one will ignore the
data/ folder, I just plan to add that in a
.gitignore file. However, I’d like the rest of the code to stay the same in both branches. So I’m afraid that every time I merge
no_data, I have to manually resolve the
One Solution collect form web for “How to I push two branches to two separate GitHub remotes?”
Don’t. This is bound to result in an error on day or another.
data directory a submodule, with its own remote upstream repo (the ‘
private_project‘ one), declared with its parent repo (which has the upstream repo ‘
That way, you can push any branch of the parent repo to ‘public_project’: it won’t matter.
All that the other contributors would get when cloning ‘public_project’ is the full repo plus a reference to another repo (‘
private_project‘), which they can’t access (because it is a private repo).
See “How exactly does git submodule work?”.