To create a new project in GitLab, follow these steps:
- Click on Create a project on the home page:
- Then, we can choose a few options:
- To create an empty project (without code)—the form asks you to enter its name:
-
- To create a new project from a built-in template project, as follows:
-
- To import code from an internal or external repository of another SVC platform, as shown in the following screenshot:
-
- The code to import is located in an external SVC repository, as shown in the following screenshot:
In our case, for this lab, we will start with the first option, which is an empty project, and as we saw in the form, we choose a project name such as BookDemo, then we validate it by clicking on the Create a project button.
- Once the project is created, we'll have a page that indicates the different Git commands to execute to push its code.
- To do this, on our local disk, we will create a new gitlabdemo directory and then clone the content of our example, which can be found at https://github.com/PacktPublishing/Learning_DevOps/tree/master/CHAP06, in the gitlabdemo directory.
- Then, we will execute the following commands in a terminal to push the code into the repository, as seen in detail in Chapter 5, Managing Your Source Code with Git:
git init
git remote add origin <git repo Url>
git add .
git commit -m "Initial commit"
git push -u origin master
During execution, an identification window will ask us for your GitLab account ID because it is a private project. Once logged into your account on the GitLab web portal, your username will be available on your account page, https://gitlab.com/profile/account.
Once these commands have been executed, we'll obtain a remote GitLab repository with our lab code.
The following screenshot shows the remote GitLab repository:
The code of our application has been deposited in GitLab, and we can now create our CI process with GitLab.