How to create a 'private fork', stay in sync with origin, and push back?

I’ve cloned a github project, and have to make some modifications in private (e.g. entering payment information). Github won’t allow me to make a forked repo private, saying I should duplicate it instead.

Following their instructions didn’t work for me (got some error, working on it with their support). Still, I don’t understand the flow – I need to be able to do all of these:

  1. Get updates from the origin repo when I need to.
  2. Keep at least one repository private.
  3. Make some changes and push them back to origin. Perhaps this will require an extra public repository.

I’m not sure what’s the best practice on how to sync all this together. Got any advice for me?

  • Pull requests overriding earlier commits
  • Merge a Pull request which is one commit behind
  • In Github, I want to auto deploy after a pull request
  • Questionnaire/Checklist for Bitbucket Pullrequest reviewers
  • Cherry-pick from closed pull request without fork branch
  • Find out if my feature branches made it to master
  • How to open multiple pull requests on GitHub
  • github pull requests: Conflicting advice on commit ranges?
  • 2 Solutions collect form web for “How to create a 'private fork', stay in sync with origin, and push back?”

    If you don’t care about pushing your commits to « save » them on a remote private server, just do a simple clone on the read-only version (local one, actually).

    Otherwise, you can use Bitbucket to push your private stuff:

    $ git clone … # the original project
    $ git remote add ghost git@bitbucket.org/your_own_repo.git
    $ git fetch origin # fetch the original
    $ git push ghost master # push the head master into your own repo
    

    When you need to update through the original project:

    $ git pull origin *the_branch*
    

    And push data to:

    $ git push ghost *the_branch*
    

    BUT like JB Nizet said, I don’t see the point here. Why just not contribute a normal way?

    If your private modifications are more private configuration values, then:

    • don’t version those values at all in a git repo (any git repo): the risk of accidently pushing them where you shouldn’t is too high.
    • store them in another referential (any cloud service allowing you to save a file, even possibly encrypted): no need for a “private fork” here.
    • only version a template of that config files, and a file with the public values.
    • use a content filter driver to:
      • check if you check out the Git repo in the right environment (like your computer)
      • if so, access your other referential, get back the values and generate the final configuration file with the right (private) values.

    smudge

    See this answer for a concrete example.

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