Site icon Student Projects Live

Understanding Git and Connecting to Your Self-Hosted GitLab

Understanding and Resolving Merge Conflicts in GIT

Git Tutorial – Part 2: Understanding Git and Connecting to Your Self-Hosted GitLab

Understanding Git and Connecting to Your Self-Hosted GitLab : In this tutorial, you will learn how to:


What is Git?

Git is a distributed Version Control System (VCS) used to:

Git works locally on your computer.


What is GitLab?

GitLab is a web-based platform that hosts Git repositories.

It allows you to:

In your environment, GitLab is hosted on your organization’s own server (self-hosted GitLab).


Git vs GitLab

GitGitLab
Installed on your computerHosted on a server
Tracks file changesStores Git repositories
Works offlineRequires network access
Command-line toolWeb application

Step 1: Sign In to Your Self-Hosted GitLab

  1. Open your web browser.
  2. Navigate to your organization’s GitLab URL.

Example:

https://gitlab.yourcompany.com
  1. Enter your username and password.
  2. Click Sign In.

Step 2: Create Your First Project

After signing in:

  1. Click New Project.
  2. Select Create Blank Project.
  3. Enter the following information.

Project Name

GitTutorial

Project Slug

gittutorial

Visibility

Choose one of the following based on your organization’s policy:

Most organizations use Private.

  1. Check the option:
Initialize repository with a README
  1. Click Create Project.

Your first repository is now created.


Step 3: Copy the Repository URL

Once the project is created:

Locate the Clone button.

You will see two options:

HTTPS

Example

https://gitlab.yourcompany.com/training/gittutorial.git

SSH

Example

git@gitlab.yourcompany.com:training/gittutorial.git

For beginners, use HTTPS unless your organization specifically requires SSH.

Copy the HTTPS URL.


Step 4: Open Visual Studio Code

  1. Open Visual Studio Code.
  2. Open the integrated terminal by selecting:
Terminal
→ New Terminal

or press

Ctrl + `

Step 5: Navigate to Your Working Folder

Example:

cd C:\Projects

If the folder does not exist:

mkdir C:\Projects
cd C:\Projects

Step 6: Clone the Repository

Run:

git clone https://gitlab.yourcompany.com/training/gittutorial.git

Example output:

Cloning into 'gittutorial'...
Receiving objects: 100%
Resolving deltas: 100%

Git downloads the repository from GitLab to your computer.


Step 7: Open the Project

Move into the project folder:

cd gittutorial

Open it in Visual Studio Code:

code .

The project is now ready for development.


Step 8: Verify the Remote Repository

Run:

git remote -v

Example output:

origin  https://gitlab.yourcompany.com/training/gittutorial.git (fetch)
origin  https://gitlab.yourcompany.com/training/gittutorial.git (push)

This confirms that your local repository is connected to the remote GitLab repository.


Step 9: Check Repository Status

Run:

git status

Example output:

On branch main

Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

This indicates:


Summary

This is all about Understanding Git and Connecting to Your Self-Hosted GitLab. You have successfully learned how to:


Next Tutorial

The next chapter will cover:

Click Here to view the Next tutorial.


Tutorial Index:

Exit mobile version