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:

  • Understand the difference between Git and GitLab.
  • Create your first project in your self-hosted GitLab server.
  • Clone a repository to your Windows 11 computer.
  • Verify the connection between your local machine and GitLab.

What is Git?

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

  • Track changes made to files.
  • Maintain a complete history of code changes.
  • Allow multiple developers to work on the same project simultaneously.
  • Restore previous versions if needed.

Git works locally on your computer.


What is GitLab?

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

It allows you to:

  • Store repositories on a central server.
  • Collaborate with team members.
  • Manage projects.
  • Review code using Merge Requests.
  • Track issues and bugs.
  • Control user permissions.

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:

  • Private
  • Internal
  • Public

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:

  • You are on the main branch.
  • Your local repository is synchronized with GitLab.
  • There are no pending changes.

Summary

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

  • Understand the roles of Git and GitLab.
  • Create a project in your self-hosted GitLab instance.
  • Clone a repository to your Windows 11 PC.
  • Open the project in Visual Studio Code.
  • Verify the remote connection.
  • Check the repository status.

Next Tutorial

The next chapter will cover:

  • Creating new files
  • Understanding the Git lifecycle
  • Using git status
  • Staging changes with git add
  • Creating commits with git commit
  • Viewing commit history with git log
  • Understanding the difference between the Working Directory, Staging Area, Local Repository, and Remote Repository

Click Here to view the Next tutorial.


Tutorial Index:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.