- A public fork of a public GitHub repository, say
facebook/react
- A private fork of the same public GitHub repository
- Keep both forks always up to date with all branches of the upstream
facebook/react
repository - Selectively publish branches from the private fork to the public fork in order to submit pull requests to
facebook/react
- A GitHub account
- A GitLab account
- A GitHub fork of the upstream repository
- A GitHub personal access token with
public_repo
access checked
- In GitLab, "create a project"
- Import from URL
[email protected]/facebook/react.git
, make sure to keep up to date
- Import from URL
- After project created, in GitLab, go to Settings -> Repository, expand "Mirroring"
- Setup "push" mirror to your public GitHub fork
- Use HTTPS clone URL with personal access token as password
- Only mirror protected branches
- Setup protected branches in GitLab, Settings -> Repository -> Protected branches
- Set the default branch of the upstream as protected
- Choose a prefix, something like
pr/*
, and mark it as protected
- Clone your private GitLab repository. Treat the default branch as the default branch of the upstream.
- Create a branch off the default branch and do some private work on it (not ready to publish yet)
- Make sure the branch does not begin with your prefix, so does NOT begin with e.g.
pr/*
when pushing it to GitLab - When ready to publish, push the branch to GitLab to a new branch with the
pr/*
prefix - The
pr/*
branch will now exist at GitHub (you can manually sync if you don't want to wait 5 minutes) - Submit a pull request to upstream using regular GitHub workflow from the
pr/*
branch
Note: this no longer works without GitLab premium :(