Skip to content

Instantly share code, notes, and snippets.

@fospathi
Last active April 23, 2020 20:27
Show Gist options
  • Save fospathi/842ee1810cbe80f0d2938374ddc12443 to your computer and use it in GitHub Desktop.
Save fospathi/842ee1810cbe80f0d2938374ddc12443 to your computer and use it in GitHub Desktop.
How to create a new GitLab project from an existing local repository

Create a new GitLab project from an existing local repository

This SSH method assumes your SSH keys are already set up on Gitlab and your local system. The SSH method is preferable as it doesn't require a username and password like the HTTPS method.

In the commands below replace fospathi and nonexistent-project with your username and project name respectively. Execute these commands in the project's top-level directory which usually contains the project's .git directory and other language specific things like a go.mod file for Go modules.

Git push using SSH

Directly push the repo to GitLab to create the new project (some times this step takes multiple attempts before success):

git push --set-upstream git@gitlab.com:fospathi/nonexistent-project.git master

Its visibility is set to Private by default (you can later change it in the project's settings).

Add remote

git remote add origin git@gitlab.com:fospathi/nonexistent-project.git

First manual push

git push -u origin master

If you're curious about the -u option see why the -u?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment