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:
- How to handle your first Pull Request on GitHub?
- How to cherry pick 2 out of 5 commits of a pull request on GitHub?
- Git pull confusion
- Squash all my commits into one for GitHub pull request
- Hosted Equivalent of GitHub Pull Request Reviews
- How do I view all Git pull requests across repositories in TFS?
- Get updates from the origin repo when I need to.
- Keep at least one repository private.
- 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?
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 email@example.com/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.
See this answer for a concrete example.