Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to fork to a private gitlab instance

Theory:

your git repository can have more than one remote server; In this case we want to have two:

  1. one for our private repository on gitlab (will be the default one, called origin)
  2. one to be connected to the source repo on github, to be able to pull new 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.extranet.weborama.com:whatever/swiper.git

  # 5. push to the private repository (track master)

  git push -u origin master

To push to gitlab / master, just use

   git push

To retrieve updates from github, use

   git pull upstream master
@ZelphirKaltstahl

This comment has been minimized.

Copy link

ZelphirKaltstahl commented Nov 7, 2016

👍

@razorness

This comment has been minimized.

Copy link

razorness commented Aug 15, 2017

If you get

error: src refspec master does not match any.
error: failed to push some refs to 'https://gitlab.foo.bar/group/project.git'

Do this as step 5:

git push -u origin --all
git push -u origin --tags
@velmuruganvelayutham

This comment has been minimized.

Copy link

velmuruganvelayutham commented Apr 15, 2018

remote: GitLab: Author '31618778+joshblakeley@users.noreply.github.com' is not a member of team
To git@it-gitlab.cloud.net:dev-group/tyk-pump.git
! [remote rejected] dev -> dev (pre-receive hook declined)

getting this error while trying to push to gitlab repo

@CLOVIS-AI

This comment has been minimized.

Copy link

CLOVIS-AI commented Feb 9, 2019

Maybe you forgot to do the git config --global user.name and user.email config ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.