Installing and Using Git on Ubuntu: A Complete Guide

Git is a powerful version control system that allows developers to track changes in their code, collaborate with others, and manage their projects efficiently. This guide will show you how to install and set up Git on Ubuntu, as well as some basic Git commands to help you get started.

← Back

Step 1: Install Git

First, update your package list to ensure you are installing the latest version of Git:

sudo apt update

Now, install Git using the following command:

sudo apt install git

Step 2: Verify Installation

After the installation is complete, you can verify that Git was installed successfully by checking its version:

git --version

If everything is working, you should see the version of Git installed, for example:

git version 2.25.1

Step 3: Configure Git

Before using Git, it is a good practice to set up your user name and email address. This information will be associated with your commits. Use the following commands to configure your Git settings:

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

These settings can be changed at any time, and they will be used for all of your Git projects. If you'd like to check your settings, use:

git config --list

Step 4: Initialize a Git Repository

Now that Git is installed and configured, you can start using it in your projects. To create a new Git repository, navigate to the project directory and run the following command:

git init

This will create a hidden .git directory, which Git uses to track changes in your project.

Step 5: Basic Git Commands

Here are some basic Git commands that will help you manage your project:

Conclusion

Git is an essential tool for developers, allowing you to track code changes, collaborate with others, and manage versions. With the installation and basic configuration covered, you can now integrate Git into your projects and start versioning your code. To dive deeper into Git, check out its official documentation for more advanced features and workflows.

← Back