I recently wanted to push a local repo I had been working on to GitLab to share with the rest of my team, but found it really hard to find out how.Hopefully this post can help someone get the information quickly!
It is actually in the doco here, but is a bit tricky to find so I’ll give a quick summary as well.
Since GitLab 10.5 it has actually just been a matter of pushing to your gitlab host and setting it as the remote. Depending on how you normally clone/push:
git push --set-upstream firstname.lastname@example.org:namespace/project-name.git master
git push --set-upstream https://gitlab.example.com/namespace/project-name.git master
You’ll obviously need:
- Use the correct domain for your GitLab instance.
- Use the namespace you want to add it to.
- Use a more descriptive name than “project-name”.
After pushing, you’ll see a message telling you need to add the remote as an origin, run that command, for example:
git remote add origin email@example.com:namespace/project-name.git
git remote add origin https://gitlab.example.com/namespace/project-name.git
And in theory that should be it!
Log in and confirm the settings are as you’d like, then you should be good to go!