Author: Kevin Clements
This tutorial is adapted from the Web Age course https://www.webagesolutions.com/courses/WA3212-ci-cd-with-gitlab.
In this tutorial, you will connect to GitLab website and run through creating a new Project.
Part 1 – Connect to GitLab
In this part, you will install the latest version of from git-scm.com and update git.
1. On the desktop click Google Chrome, to start the web browser.
2. In the URL, type in:
The git page will open.
3. Click the link for the 64-bit Git for Windows Setup and when downloaded click the .exe file to run the installer from the lower left link in the browser.
4. Click Run in the dialogue box popup and follow the prompts.
During installation use the defaults, but you can override the branch choice to be “main”.
5. If Git Bash does not open when finished installation, Click the Windows Orb in the bottom left to run Git Bash directly.
6. In Windows Search, type Git Bash or navigate to Git Bash in the apps window. Double click the icon shown below.
7. Leave the new Git Bash prompt open for now. We will come back to it shortly.
Part 2 – Create an Account – or Login if already existing
In this part, you will create a new account on the GitLab UI web server.
1. Register/Sign up for a GitLab account:
2. You may need to confirm your email address via an email sent from GitLab. Check
your junk folder just in case.
Part 3 – Login to GitLab
In this part, you will login to GitLab.com
1. Log in to your acco,unt.
2. Enter your email/username and password then click Sign in.
Part 4 – Create a new Project
In this part, you will create a new GitLab Project.
1. After logging in, click on the New Project button or the Create a project button to create a new project or use the dropdown Menu. Your window may be different than below.
2. Next, choose the Create Blank Project button.
3. Now enter a name, a description, target, and whether you want it to be private or
publicly visible. For example:
Project Name: tutorial
Project Description: This is my Demo tutorial
Viability Level: Private
Project Deployment Target: No deployment planned
Project configuration: Leave the Project Configuration checked for README
. Click the Create Project button.
5. In the updated browser window, review the tutorial project just created. This should show the new project created, any commits or branches, author, etc.
6. Look specifically at the README.md created.
7. Notice the command-line instructions for adding files, etc.
8. Leave the connection to GitLab.com open once you finished reviewing items.
Part 5 – Setting up GitLab connection from workstation
In this part we will now setup a local working folder on the VM workstation to integrate
with our tutorial page main branch at GitLab.com
1. In the workstation return to the Git Bash window you started in Part 1.
2. We will now configure git with a new username and email associated with the GitLab.com site information. Replace the email address with your email address used to
create the GitLab.com login. In the Git Bash window run the following:
git config –global user.name “tutorial”
git config –global user.email youremailusedtologinonGitLab
3. In the new command prompt, create a new folder for your project called “tutorial”:
4. Change into the tutorial folder using cd command and see what’s there, use dir. The folder should be empty:
5. Ensure Git is available on the current workstation. Type “git” at the prompt:
You should see a listing of the Git command and examples of their usage.
Take a moment to review the commands and if need reading further about these as
needed from https://www.atlassian.com/git/glossary
6. Now initialize the folder to work with Git. Use the “git init” command. Ensure you are located under the c:\tutorial folder when your run the command:
7. Now type “git status”. Whenever a Git repository is created for the first time, it creates a branch, and it’s called the master:
Notice that “On branch master” appears on the screen.
8. Earlier we observed the Add your files area on the GitLab.com site after creating our tutorial project. Return to the web page and look at the information.
9. We can add the remote connection information and change the branch by declaring it using the syntax highlighted. Your remote https:// path may differ, ensure you use the one from the web page you are on:
git remote add origin https://gitlab.com/webage/tutorial.git
git branch -M main
Leave the Git Bash window open for now.
Part 6 – Adding an SSH Public and Private Key
Git is a distributed version control system, create code locally, then share or push code changes to the GitLab server. GitLab uses the SSH protocol to securely communicate with Git. When you use SSH keys to authenticate to the GitLab remote server, you don’t need to supply your username and password each time.
You may have already seen this indication earlier while on GitLab.
1. Open a Command prompt window.
2. Check that the VM workstation supports ssh. Here the returned item is OpenSSH:
Most computers already have some SSH tools installed natively. If you didn’t see this you would need to install OpenSSH or some other SSH library on your computer.
Now we can generate a private and public key to be used. The key should be given a unique type and can have a comment like an email address to identify it.
3. We will use the type ed25519, a standard ssh type, and add a comment using -C.
Replace the example “” with your actual email address:
ssh-keygen -t ed25519 -C “”
4. Use the default file location when prompted. You will be asked to enter a passphrase which may be needed anytime you commit and push code to GitLab. Make it something you can remember easily for the lab step 8 like 123abc for instance.
This file will be generated in c:\users\wasadmin.ssh folder. Look at that location and find the file ending in .pub extension. This file will need to be opened and contents copied to GitLab.com site.
5. We will now copy the file contents mentioned id_ed25519.pub to our GitLab SSH Key preferences. The contents will start with:
6. In Notepad copy the contents of the id_ed25519.pub file. It should look similar to this, where is your email:
7. Return to or open GitLab.com again from your browser. Make sure you are logged in to the site and select Preferences from the right hand Orb image link as shown.
8. This opens the SSH window to allow for the inclusion of the SSH Key information copied previously. Click the SSH keys from the left menu.
9. Paste the copied ssh key information into the box labeled as Key, add a title like VM Workstation, and set an Expiration date in the future like a year from today’s date for instance.
10. Click Add Key.
11. Return to the Gitbash window and test to ensure the ssh key works from the local VM to the remote GitLab server. Use the following command, you may be asked for your email address and the passphrase created in the earlier step:
ssh -T firstname.lastname@example.org
This should return your actual username: Welcome to GitLab, !
Part 7 – Adding to the GitLab repository
Now it’s time to work with our local code and add file to the remote repository.
1. Return to the git bash command and make sure you are in the c:\tutorial folder.
2. Use the command “git status” or “git branch” to check for the current branch you are working with, it should say “main”.
3. Best practice would be to add a branch to work with our code on. Create one called “example” and move into that branch using “git checkout”:
git checkout -b example
4. Use the “git status” command to see where you are now:
5. Now, create a notepad text file for the repository, press Y to create the file:
6. Later on, you can push that file onto the GitLab repository. Inside the file add the
“Hello from GitLab”
7. Save the file, and close notepad when complete.
8. The file is ready to use with our repository now, we need to add it and commit it
notice the dot notation commits everything, or we could have said “git add input.txt” too.
When using commit the syntax is: git commit -m “DESCRIBE COMMIT IN A FEW
git add .
git commit -m “input”
9. Check the status of the local git environment:
The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repository branches. “git fetch” can be used to fetch or import commits to local branches.
10. Now we have a new branch and a new file in that branch called input.txt to upload
to the remote repository. Here we can use the “git push” command to sink the file:
git push -uf origin example
11. You may be requested to enter you user name and password, if so do it:
You will see a result similar than this:
Next you will check if the file you committed and push was successfully added to the
repository under the example branch.
12. Go back to your gitlab browser and click the home menu.
13. Click on your project.
14. Click main and you should see the branches and click the example branch.
15. Having selected the example branch the file input.txt that was pushed should be listed below. Click on the file name to view its contents.
You should see the text “Hello from GitLab” added earlier.
16. Return to the VM github VM prompt and reopen the input.txt file:
17. In the file add a new line below the first text as follows:
Hello world! I’m using Git!
18. Save and close the file.
19. Now run the “git status” command again:
20. Add and Commit the updated file:
git add input.txt
git commit -m “I add text to the input file”
21. Now push the changes to the remote repository using “git push”:
git push origin example
Again you may be requested for user and password and you will get a result like this:
22. Return to the GitLab.com site and refresh that page. Note the change.
23. Return to the main branch:
git branch -M main
24. Leave the VM command prompt open and the browser open to GitLab.com site.
Part 8 – Review
In this tutorial, you created an initial GitLab project and uploaded a file to the remote