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 master and 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 no_data branch.

Questions:
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 master to no_data, I have to manually resolve the .gitignore merge.

  • Git/Github workflow for students and projects
  • Elegant solution to prevent force push on master only
  • Git: 'rebase' is not a git command. See 'git --help'
  • How to delete a remote git commit HEAD?
  • fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
  • git clone gets gh-pages, I want it to clone master (from Github)
  • How to compile forked library in Gradle?
  • Git flow and Github
  • 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.

    Make the data directory a submodule, with its own remote upstream repo (the ‘private_project‘ one), declared with its parent repo (which has the upstream repo ‘public_project‘).

    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?”.

    Git Baby is a git and github fan, let's start git clone.