To create a project in GitLab, we can proceed in two different way: trough the Gitlab-web-plattform or throug the command line. Let´s now see clearly how.
Create a project in GitLab
To create a project in GitLab:
- In your dashboard, click the green New project button or use the plus icon in the navigation bar. This opens the New project page.
- On the New project page, choose if you want to:
- Create a blank project.
- Create a project using with one of the available project templates.
- Import a project from a different repository, if enabled on your GitLab instance. Contact your GitLab admin if this is unavailable.
- Run CI/CD pipelines for external repositories.
Push to create a new project
Introduced in GitLab 10.5.
When you create a new repository locally, instead of going to GitLab to manually create a new project and then clone the repo locally, you can directly push it to GitLab to create the new project, all without leaving your terminal. If you have access rights to the associated namespace, GitLab will automatically create a new project under that GitLab namespace with its visibility set to Private by default (you can later change it in the project’s settings).
This can be done by using either SSH or HTTPS:
## Git push using SSH
git push --set-upstream git@gitlab.example.com:namespace/nonexistent-project.git master
## Git push using HTTPS
git push --set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master
Once the push finishes successfully, a remote message will indicate the command to set the remote and the URL to the new project:
remote:
remote: The private project namespace/nonexistent-project was created.
remote:
remote: To configure the remote, run:
remote: git remote add origin https://gitlab.example.com/namespace/nonexistent-project.git
remote:
remote: To view the project, visit:
remote: https://gitlab.example.com/namespace/nonexistent-project
remote: