Understanding and Iinitializing Git : From installation to clone a branch

Git is a powerful version control system that enables developers to manage and track changes in their codebase effectively. GitLab, a web-based platform, leverages Git and provides a collaborative space where developers can host, manage, and track their code. This guide will walk you through the initial steps of setting up and initializing Git, focusing on GitLab’s functionalities and interface. By understanding these fundamental concepts, you can efficiently work with code repositories and contribute to projects on GitLab.

1. Getting Started: Installing Git

Before you can start using Git and GitLab, you need to install Git on your local machine. The installation process varies depending on the operating system you are using.

Windows:

  1. Download the latest Git for Windows installer from here.
  2. Run the installer and follow the prompts to complete the installation.
  3. To check the installation, open a command prompt and type git –version.

macOS:

  1. Open Terminal and install Git using Homebrew by running: brew install git.
  2. To check the installation, type git –version.

Linux:

  1. Open a terminal window.
  2. Use the package manager to install Git. For example, on Ubuntu, run: sudo apt-get install git.
  3. To verify the installation, type git –version.

2. Configuring git

After installation, configure Git with your user information. This information is crucial as it is associated with your commits.

git config --global user.name "Sachin India"
git config --global user.email "sachin@freshers.in"

3. Initializing a new repository with git init

Once Git is installed and configured, you can initialize a new repository. This is the first step in creating a project that you can manage using Git.

  1. Navigate to the directory where you want to create your project.
  2. Open a terminal window in this directory.
  3. Type git init to initialize a new Git repository.

4. Setting up and working with GitLab repositories

a. Cloning a repository

To work with an existing repository on GitLab, clone it to your local machine using the git clone command. For example:

Feature branch:

git checkout -b feature-frehers-in-viewership-2024-9878

Release branch:

git checkout -b release-frehers-in-sept-2023-v01

c. Creating merge requests

Merge Requests are essential in GitLab to incorporate changes from one branch into another.

GitLab documentation

Read more on Git here

Author: user

Leave a Reply