How to create GitLab project from Ubuntu Terminal ?

In continuation with the articles for using “GitLab” , In this post, we will demonstrate how to create a GitLab project from Ubuntu Terminal or Linux command line, so that you could be easily able to create new repositories and push the code automatically using bash scripts.

Prerequisite: Make sure you have added the SSH key to GitLab account and its verified as mentioned in “How to add SSH keys in GitLab ?

Now, consider you have a Group Named “lynxbeedev” (Use your GitLab group name) and you want to create a project “repository_created_from_ubuntu_terminal.git” (You can use your project name) then the repository URL for gitlab becomes as “https://gitlab.com/lynxbeedev/repository_created_from_ubuntu_terminal.git”

Now, this repository / project can be created automatically from command line as,

$ git push --set-upstream git@gitlab.com:/lynxbeedev/repository_created_from_ubuntu_terminal.git

Which is in general as,

$ git push --set-upstream git@gitlab.com:/group_name/project_name.git

Then if successful, we can see the logs as,

$ git push --set-upstream git@gitlab.com:/lynxbeedev/repository_created_from_ubuntu_terminal.git 
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 276 bytes | 276.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: 
remote: The private project lynxbeedev/repository_created_from_ubuntu_terminal was successfully created.
remote: 
remote: To configure the remote, run:
remote:   git remote add origin git@gitlab.com:lynxbeedev/repository_created_from_ubuntu_terminal.git
remote: 
remote: To view the project, visit:
remote:   https://gitlab.com/lynxbeedev/repository_created_from_ubuntu_terminal
remote: 
remote: 
remote: 
To gitlab.com:/lynxbeedev/repository_created_from_ubuntu_terminal.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'git@gitlab.com:/lynxbeedev/repository_created_from_ubuntu_terminal.git'.

Now, if you visit your GitLab account using browser, you can see the project got created under group,

Leave a Comment