doc/topics/git/project.md
{{< details >}}
{{< /details >}}
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.
[!note] You cannot use
git pushto 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:
<!--- To push with SSH, you must have [an SSH key](../ssh.md) that is [added to your GitLab account](../ssh.md#add-an-ssh-key-to-your-gitlab-account). -->You must have permission to add new projects to a namespace. To verify your permissions:
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.00 to your project's required port number.--tags flag to
your git 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.