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:

  • git - exclude commits when rebasing
  • Why git difftool does not open vimdiff in case of conflicts?
  • Command to list branches on particular server
  • bitbucket git push authentication failed (mac os x)
  • What happened if I didn't add a dot at the end of `git checkout `?
  • Git over ngrok tunnel forwarding
    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?

  • Host key verification failed Xcode with Mavericks Server
  • How do I search the content of tag annotations in git?
  • How do I push a local Git branch to master branch in the remote?
  • Why do we need to git push first before git pull?
  • no git repository but all the git stuff is there
  • Teamcity REST API get latest successful build on a branch
  • 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 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.


    See this answer for a concrete example.

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