Create a project with git push
You can use git push
to add a local project repository to GitLab. After you add a repository,
GitLab creates your project in your chosen namespace.
git push
to create projects with paths that were previously used or
renamed.
Previously used project paths have a redirect. Instead of creating a new project,
the redirect causes push attempts to redirect requests to the renamed project location.
To create a new project for a previously used or renamed project, use the UI
or the Projects API.Prerequisites:
-
You must have permission to add new projects to a namespace. To verify your permissions:
- On the left sidebar, select Search or go to and find your group.
- In the upper-right corner, confirm that New project is visible.
If you do not have the necessary permission, contact your GitLab administrator.
To create a project with git push
:
-
Push your local repository to GitLab with one of the following:
-
With SSH:
-
If your project uses the standard port 22, run:
git push --set-upstream [email protected]:namespace/myproject.git main
-
If your project requires a non-standard port number, run:
git push --set-upstream ssh://[email protected]:00/namespace/myproject.git main
-
-
With HTTP, run:
git push --set-upstream https://gitlab.example.com/namespace/myproject.git master
Replace the following values:
-
gitlab.example.com
with the machine domain name hosts your Git repository. -
namespace
with your namespace name. -
myproject
with your project name. - If specifying a port, change
00
to your project’s required port number. - Optional. To export existing repository tags, append the
--tags
flag to yourgit push
command.
-
-
-
Optional. Configure the remote:
git remote add origin https://gitlab.example.com/namespace/myproject.git
When the git push
operation completes, GitLab displays the following message:
remote: The private project namespace/myproject was created.
To view your new project, go to https://gitlab.example.com/namespace/myproject
.
By default, your project’s visibility is set to Private,
but you can change the project’s visibility.