Course Content
GIT Tutorial
About Lesson

Installing Git on Linux

Git is a powerful version control system that plays a crucial role in modern software development. It allows multiple developers to collaborate on a project efficiently and track changes seamlessly. Installing Git on Linux is a fundamental step towards leveraging its benefits for your development workflow.

Checking Existing Git Installation

Before installing Git, it’s a good practice to check if it’s already installed on your Linux system. Open a terminal and type the following command:

git --version

If Git is installed, you’ll see the version number. If not, proceed to the installation steps.

Installing Git on Debian-based Systems (e.g., Ubuntu)

For Debian-based systems, including Ubuntu, use the package manager to install Git:

sudo apt update
sudo apt install git

Installing Git on Red Hat-based Systems (e.g., CentOS)

For Red Hat-based systems like CentOS, use the following commands:

sudo yum install epel-release
sudo yum install git

Configuring Git After Installation

Once Git is installed, configure it with your name and email. This information will be associated with your commits:

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Verifying Git Installation

To confirm that Git has been installed successfully, run:

git --version

This should display the Git version without any errors.

Basic Git Commands to Get You Started

Now that Git is installed, let’s cover a few essential commands to kickstart your version control journey:

Initializing a Repository

To start version controlling a project, navigate to your project’s directory and run:

git init

Cloning a Repository

If you’re collaborating on an existing project, use the git clone command:

git clone [repository_url]

Replace [repository_url] with the actual URL of the repository.

Adding and Committing Changes

After making changes to your files, use these commands to stage and commit them:

git add .
git commit -m "Your commit message here"