Compartmentalized
|
Documented
|
Extendible
|
Reproducible
|
Robust
|
GitLab to GitHub Migration
This if for migrating repos from one INTERNAL GitLab server to another. This is geared to RStudio users.
Although this is long, that is because I went into every single step in detail. It’s actually quite easy.
- Make the blank repo on
- In RStudio, update the .git/config file with the new github url
- Click Push
Let’s give the URL for the internal GitHub and GitLab the following names:
Obviously replace with the real URLs. It won’t be anything like that.
Make a blank repo on GitHub
- Let’s say my repo on GitLab is TestPackage1.
- Look in upper right for the + sign. Click that and click New Repository.
- Give the new repo the same name as the GitLab repo. So I will call it TestPackage on github.nwfsc2.noaa.gov
- Click Create Repository. Private/Public doesn’t matter. DO NOT click the boxes to add a README or .gitignore!
- Ignore the page that comes up saying ‘Quick Set-up’ etc. Just stop there and go to the next step below.
Leave the browser and go to RStudio.
- Open up the project with the files that are in your GitLab repo. So I open my TestPackage project in RStudio.
- Don’t have those files locally? See instructions below to get those to get a copy locally and as a project in RStudio.
- In RStudio, look for the ‘More’ cog in the Files pane, Click that and make sure is shows ‘Show Hidden Files’
- Open the .git folder in the Files pane. Click on ‘config’ to open that file.
- Look for the line that says ’url = https://gitlab.XYZ.local
- Change https://gitlab.XYZ.local to https://github.XYZ.local. Everything else stays the same.
So for me that line changes from
url = https://gitlab.XYZ.local/eholmes/TestPackage to
url = https://github.XYZ.local/eholmes/TestPackage
- Save.
- Click the Git tab (just above the File pane), and click the upward Green arrow.
- It’ll ask you for a password the first time you do this. You’ll see a pop-up window, but it won’t tell you that it is done.
Back to the GitHub server
Troubleshooting
Don’t have your GitLab repo on your computer?
- Copy the url of the repo. So like https://gitlab.XYZ.local/eholmes/TestPackage
- Open RStudio and click File > New Project > Version Control > Git and paste the URL into Repository URL.
- Note give some thought to where you keep repos on your local computer. I keep all of mine in one folder called GitHub in my Documents folder. You might lose track of them if you don’t keep them in the same spot.
- Click Create Project
You have the GitLab repo on your computer but it is not an RStudio project.
- Open RStudio and click File > New Project > Existing Folder > Git and paste the URL into Repository URL.
- Click Create Project > Existing Directory then navigate to the folder with the repo on your computer.
When I click Push, I get an error that RStudio doesn’t know how to get my GitHub credentials. Sorry, that’s a pain. You need to tell RStudio how to get that info.
I got the error ‘Repo not found’ when I clicked push
I got an error saying cannot merge because of conflicting histories (or something like that)
- You clicked the boxes and created a ReadME or .gitignore file when you created the repo on github.nwfsc2.noaa.gov.
- Go back to the repo on https://github.XYZ.local.
- Click Settings (nav bar just above the big green Code button)
- Scroll down and delete the repo
- Create it again and this time don’t click one of those check boxes that makes a Readme or .gitignore file
I did what you said but when I go to https://github.XYZ.local, I don’t see the files. It still shows the Quick Set-up instructions.
More help on working with GitHub is here
NWFSC Math Bio Program