Have a public repo on github for the world to see + have a the same repo private on gitlab for project specific branches/dev. Locally use github as upstream and gitlab as origin. We develop in gitlab and push general applicable changes to our upstream github repo.
In detail:
- one for our private repository on gitlab (will be the default one, called
origin
) - one to be connected to a repo on github, to be able to publish new general changes (will be called
upstream
)
How to make a private fork from github to gitlab
# 1. clone the github project in your workspace
git clone git@github.com:whatever/repo.git
# 2. rename the remote
git remote rename origin upstream
# 3. Create a new repo in gitlab website
# 4. Add the new origin to your repo
git remote add origin git@gitlab.newname.git
# 5. push to the private repository (track master)
git push -u origin --all
git push -u origin --tags
To push to gitlab / master, just use
git push
To retrieve updates from github, use
git pull upstream master
git fetch --all --tags
Push new developments from a project branch to upstream, use
git checkout -b project1
# do whatever you want
# push to private repo
git push origin project1
# Oh done some generally useful changes ...
git checkout -b dev
git merge project1
git push upstream dev
# create a merge request with master on github