Git is a powerful distributed version control system that has become the standard for modern software development. Whether you’re contributing to open source projects or managing your own repositories, Git is an essential tool for developers.
In this blog post, we’ll walk through how to install Git on various Linux distributions and verify your installation to ensure you’re ready to start using Git effectively.
What Is Git?
Git is a free and open-source version control system designed to handle everything from small to very large projects with speed and efficiency. Created by Linus Torvalds in 2005, Git is known for its distributed nature, strong branching capabilities, and high performance.
Prerequisites
Before installing Git, make sure you:
- Have sudo (administrator) access to your Linux system.
- Have a stable internet connection to download packages.
Installing Git on Popular Linux Distributions
1. Ubuntu / Debian-Based Systems
Use the apt
package manager:
sudo apt update
sudo apt install git
After installation, verify Git with:
git --version
2. Fedora
Use the dnf
package manager:
sudo dnf install git
Check the version:
git --version
3. CentOS / RHEL
For CentOS 7 or RHEL:
sudo yum install git
For CentOS 8 or newer (which uses dnf
):
sudo dnf install git
Then verify:
git --version
4. Arch Linux / Manjaro
Use the pacman
package manager:
sudo pacman -S git
Verify with:
git --version
Alternative: Installing Git from Source
If you need a newer version than what’s available in your package manager:
Step 1: Install Dependencies
sudo apt update
sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
Step 2: Download the Latest Source
curl -o git.tar.gz https://mirrors.edge.kernel.org/pub/software/scm/git/git-<version>.tar.gz
tar -zxf git.tar.gz
cd git-<version>
Replace <version>
with the desired release number, e.g., 2.43.0
.
Step 3: Compile and Install
make prefix=/usr/local all
sudo make prefix=/usr/local install
Check your installation:
git --version
Post-Installation Setup
Once installed, configure Git with your identity:
git config --global user.name "Your Name"
git config --global user.email "yo*@ex*****.com"
You can view your configuration with:
git config --list
Conclusion
Installing Git on Linux is a straightforward process, whether you’re using a package manager or compiling from source. Once installed, you’ll be able to create repositories, track changes, and collaborate on projects with confidence.
Keeping Git up to date ensures access to the latest features and security improvements. Be sure to also explore Git configuration options and tools like SSH keys, Git aliases, and credential helpers to enhance your development workflow.