Skip to content

Instantly share code, notes, and snippets.

@rmacster
Created May 12, 2022 20:16
Show Gist options
  • Save rmacster/2c13d463c5580efeb612fd5f028dde9e to your computer and use it in GitHub Desktop.
Save rmacster/2c13d463c5580efeb612fd5f028dde9e to your computer and use it in GitHub Desktop.
Move a github repo to gitlab
To move a repo to gitlab from github:
1. create ssh keys for gitlab if needed.
very good instructions for this step are on the gitlab site. See:
https://docs.gitlab.com/ee/user/ssh.html
2. tell ssh how to access those keys if they're in a different directory.
eval $(ssh-agent -s)
ssh-add /home/azureuser/.ssh/gitlab/id_ed25519 // the path to your gitlab ssh keys
to make the above permanent, use the command: "nano ~/.ssh/config" to add the ssh key information to .ssh/config file like:
Host gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/gitlab/id_ed25519
after creating/editing the config file make sure its permissions are 600 with the command:
chmod 600 ~/.ssh/config
3. within gitlab, create an empty gitlab repo with the same name as the old github repo.
4. clone that repo to a new directory on the same system that has the old github repo.
git clone git@gitlab.com:yourGitlabAcct/yourNewOldRepo.git
5. copy the contents of the old repo to the newly cloned directory.
cp -rf /home/user/github/some-repo/* /home/user/gitlab/some-repo/*
6. enter the new directory and set some basic user information.
git config --global user.name "My Name" // gitlab user name
git config --global user.email "myEmail@gmail.com" // associated gitlab user email address
7. add, commit, and push the newly copied files to your gitlab repo.
git add .
git commit -m "initial commit"
git push
Note: this will create the repo on gitlab as if it were a brand new repo, with none of the history.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment