How to Install Git on Linux Mint

Git tracks every change you make to code, configuration files, or documentation, creating a complete history you can navigate, compare, and restore at any point. Whether you need to roll back a breaking change in your web application, collaborate with contributors on a shared repository, or maintain multiple feature branches for a personal project, Git gives you the branching, merging, and commit workflows to manage updates without losing work or overwriting teammate contributions.

This guide covers three installation methods: the default Linux Mint repository for stability and automatic security updates, the Ubuntu Git Maintainers PPA for the latest stable releases, and source compilation for complete control over build options. By the end, you will have Git configured with your identity (name and email), SSH authentication for remote repositories, and the knowledge to manage commits, branches, and pushes to platforms like GitHub or GitLab.

Choose Your Git Installation Method

Linux Mint offers several ways to install Git, each with different trade-offs between version freshness, update convenience, and maintenance requirements.

MethodChannelVersionUpdatesBest For
Default RepositoryUbuntu ReposDistribution defaultAutomatic via apt upgradeMost users who prefer stability and security
Ubuntu Git PPALaunchpad PPALatest stableAutomatic via apt upgradeDevelopers needing newest features
Source CompilationGit tagsAny releaseManual recompilationAdvanced users requiring custom builds

Linux Mint uses Ubuntuโ€™s package repositories, so package availability follows the Ubuntu LTS release your Mint version is based on. The mapping is: Linux Mint 22.x (Wilma, Xia, Zara, Zena) uses Ubuntu 24.04 LTS (noble) with Git 2.43.0, while Linux Mint 21.x (Vanessa, Vera, Victoria, Virginia) uses Ubuntu 22.04 LTS (jammy) with Git 2.34.1. The PPA provides Git 2.52.0 for both versions. Commands in this guide work identically across all supported Mint releases unless noted otherwise.

For most users, the default repository method is recommended because it provides automatic security updates through standard system maintenance. Only use the PPA if you specifically need features from newer Git releases, and only compile from source if you require custom build options or need to test patches.

Update Linux Mint Before Git Installation

Before starting the installation process, update your Linux Mint system to ensure all packages are current and avoid conflicts during the installation. Open a terminal from the applications menu or by using the keyboard shortcut configured on your system.

Run the following command to update the package lists:

sudo apt update

Then upgrade any outdated packages by running the following:

sudo apt upgrade

Method 1: Install Git with APT

APT offers two approaches: installing from the default Linux Mint repository or adding a third-party PPA for newer versions. The default repository provides a stable Git version tested against your system libraries, while the PPA delivers the latest upstream releases.

Install Git from the Default Repository

The default Linux Mint repository includes a stable Git version that receives security updates through standard system maintenance. Many Linux Mint installations already include Git, so start by checking whether it exists on your system.

First, check if Git is already installed:

git --version

When Git exists on your system, the command returns output showing the installed version. The exact version depends on your Linux Mint release:

git version 2.43.0  # Linux Mint 22.x (Ubuntu 24.04 noble)
git version 2.34.1  # Linux Mint 21.x (Ubuntu 22.04 jammy)

Without Git installed, the terminal displays an error message:

Command 'git' not found, but can be installed with:

sudo apt install git

Install Git with the following command:

sudo apt install git

The installation will download and configure Git. Once complete, you will see output confirming the package installation:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  git
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,910 kB of archives.
After this operation, 26.1 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 git amd64 1:2.43.0-1ubuntu7 [3,910 kB]
Fetched 3,910 kB in 1s (3,200 kB/s)
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.43.0-1ubuntu7_amd64.deb ...
Unpacking git (1:2.43.0-1ubuntu7) ...
Setting up git (1:2.43.0-1ubuntu7) ...
Processing triggers for man-db (2.11.2-2) ...

The output above shows a Mint 22 installation. On Mint 21, you will see version 2.34.1 instead of 2.43.0. After installation completes, verify Git is working:

git --version

The output confirms the installed version, which matches the default for your Mint release:

git version 2.43.0  # Linux Mint 22.x
git version 2.34.1  # Linux Mint 21.x

Install Git from the Ubuntu Git Maintainers PPA

For users who prefer the latest stable version of Git, the Ubuntu Git Maintainers PPA provides newer releases than the default repository. Linux Mint builds on Ubuntu LTS, making this PPA fully compatible with your system.

Import the Stable Branch PPA

Add the stable branch of the Ubuntu Git Maintainers PPA by running:

sudo add-apt-repository ppa:git-core/ppa -y

Import the Release Candidate Branch PPA (Optional)

Alternatively, if you want to test upcoming features, you can add the release candidate branch, which contains pre-release versions for testing. Most users should stick with the stable branch above, but you can add both if you want to test upcoming features.

Add the release candidate branch by running:

sudo add-apt-repository ppa:git-core/candidate -y

After importing either PPA, refresh the package lists and install Git:

sudo apt update

Next, check the available Git versions to confirm you successfully added the PPA:

apt-cache policy git

This command displays the available Git versions from configured repositories. You should see output similar to:

git:
  Installed: (none)
  Candidate: 1:2.52.0-0ppa1~ubuntu24.04.1
  Version table:
     1:2.52.0-0ppa1~ubuntu24.04.1 500
        500 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu noble/main amd64 Packages
     1:2.43.0-1ubuntu7 500
        500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages

The PPA version (2.52.0 in this example) appears as the candidate, confirming you successfully added the repository. The Ubuntu URLs in the output are expected because Linux Mint uses Ubuntuโ€™s package repositories as its base.

Now install Git using the following command:

sudo apt install git -y

This command works for both users with and without Git installed.

Verify the installation by checking the Git version:

git --version

You should see the newer PPA version:

git version 2.52.0

Method 2: Install Git via Source Archive

Compiling Git from source gives you access to the absolute latest version and lets you customize compile-time options. This method requires more steps but is useful when you need features not yet available in packaged releases.

Install Git Build Dependencies

Before compiling Git, you need to install the necessary build dependencies. Run the following command to install them:

sudo apt install make libssl-dev zlib1g-dev libcurl4-gnutls-dev libexpat1-dev gettext -y

Download Git Source Code

The following command automatically fetches the latest stable Git release from GitHub and downloads it to your current directory:

GIT_VERSION=$(curl -s https://api.github.com/repos/git/git/tags | grep -oP '"name": "\Kv[0-9]+\.[0-9]+\.[0-9]+"' | head -1 | tr -d '"')
wget "https://github.com/git/git/archive/refs/tags/${GIT_VERSION}.tar.gz" -O git-source.tar.gz
echo "Downloaded Git ${GIT_VERSION}"

This command queries the GitHub API for available tags, filters for stable releases (excluding release candidates), and downloads the latest version. Alternatively, you can manually visit the Git tags page to select a specific version.

Extract and Compile Git Source Code

Once the download completes, extract the archive and navigate into the source directory:

tar -xzf git-source.tar.gz
cd git-*/

Now compile Git using the make command. The prefix=/usr/local option specifies where the installation will place Git:

sudo make prefix=/usr/local all

This compiles all Git components. Once compilation finishes, install Git to your system:

sudo make prefix=/usr/local install

Git now resides in /usr/local/bin, which takes priority over /usr/bin in your system PATH. As a result, the system will use your compiled version instead of any APT-installed Git package. Verify the installation:

git --version

You should see the version you compiled:

git version 2.52.0

Configure Git Identity

Before using Git, configure your identity. Git attaches this information to every commit you make, which is essential for collaboration and contribution tracking on platforms like GitHub, GitLab, and Bitbucket. This configuration is also required before Git allows you to create commits.

Set your name:

git config --global user.name "Your Name"

Then set your email address (use the same email you use for GitHub, GitLab, or other hosting services if you plan to push code):

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

Verify your configuration:

git config --list

The output displays your global Git configuration. At minimum, you should see your name and email:

user.name=Your Name
user.email=your.email@example.com

Git stores these global settings in ~/.gitconfig and applies them to all repositories on your system. When you run this command inside a Git repository, you may see additional settings like core.repositoryformatversion and core.filemode that apply only to that specific repository. To override global settings for a single project, run the same git config commands without the --global flag while inside the project directory.

Troubleshooting Common Git Issues

This section covers common issues you may encounter when using Git on Linux Mint and provides clear solutions with verification steps.

Permission Denied When Pushing to Remote Repository

If you cannot push commits to GitHub or GitLab, you will see an authentication error:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

This occurs when Git cannot authenticate with the remote server because you have not configured an SSH key. To resolve this, generate an SSH key pair and add the public key to your hosting service:

ssh-keygen -t ed25519 -C "your.email@example.com"

Press Enter to accept the default file location and optionally set a passphrase. Next, display your public key:

cat ~/.ssh/id_ed25519.pub

Copy the output and add it to your GitHub or GitLab account under SSH keys in account settings. Then test the connection:

ssh -T git@github.com

A successful connection shows:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Git Commands Use Wrong Version After Multiple Installations

If you installed Git from both APT and source, the wrong version may run. Check which Git binary is active:

which git

The output shows the path Git is using:

/usr/local/bin/git

Source-compiled installations in /usr/local/bin take priority over APT packages in /usr/bin. If you want to use the APT version instead, remove the source installation as described in the Remove Git section below, then verify:

which git && git --version

Confirm the path changed and the version matches your expectations.

Fatal Error: Not a Git Repository

Running Git commands outside an initialized repository produces this error:

fatal: not a git repository (or any of the parent directories): .git

This means you are not in a directory tracked by Git. Either navigate to an existing repository or initialize a new one:

git init

Verify Git created the repository:

ls -la | grep .git

You should see a .git directory confirming the repository exists.

Get Started with Git Commands

With Git installed and configured, you can start tracking code changes immediately. This section covers the essential commands for creating repositories, committing changes, and pushing to remote platforms. For comprehensive Git tutorials, see the official Git documentation.

Initialize or Clone a Repository

Create a new local repository in the current directory:

git init

Alternatively, if working with an existing project, clone an existing remote repository:

git clone https://github.com/username/repository.git

This creates a local copy of the repository with full history and tracking configured automatically.

Check Repository Status

View which files changed, which you have staged, and which branch you are on:

git status

This command shows untracked files, modified files, and staged changes ready for commit.

Stage and Commit Changes

Add specific files to the staging area:

git add filename.txt

Or stage all changes in the current directory:

git add .

Then record the staged changes with a descriptive commit message:

git commit -m "Add feature X to improve performance"

Create and Switch Branches

Start a new branch for feature development:

git branch feature-branch

Then switch to the new branch:

git checkout feature-branch

Or create and switch in one command:

git checkout -b feature-branch

Push Changes to Remote Repository

After committing locally, push changes to the remote repository:

git push origin main

Replace main with your branch name. For example, for new branches, use:

git push -u origin feature-branch

The -u flag sets the upstream tracking so future pushes only require git push.

Manage Git Installation

Update Git

For APT installations (default repository or PPA), Git updates arrive through standard system upgrades:

sudo apt update && sudo apt upgrade

For source-compiled installations, you can create a reusable update script. First, create a new script file in your home directory:

nano ~/update-git.sh

Paste the following script into the editor:

#!/bin/bash
# Git Source Update Script for Linux Mint
# This script downloads and compiles the latest stable Git release

set -e  # Exit on any error

echo "Checking for latest Git version..."
GIT_VERSION=$(curl -s https://api.github.com/repos/git/git/tags | grep -oP '"name": "\Kv[0-9]+\.[0-9]+\.[0-9]+"' | head -1 | tr -d '"')

echo "Current installed version: $(git --version)"
echo "Latest available version: Git ${GIT_VERSION}"
echo ""
read -p "Continue with update? (y/n) " -n 1 -r
echo ""

if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo "Update cancelled."
    exit 0
fi

echo "Downloading Git ${GIT_VERSION}..."
cd /tmp
wget -q "https://github.com/git/git/archive/refs/tags/${GIT_VERSION}.tar.gz" -O git-source.tar.gz

echo "Extracting source code..."
tar -xzf git-source.tar.gz
cd git-*/

echo "Compiling Git (this may take a few minutes)..."
make prefix=/usr/local all -j$(nproc)

echo "Installing Git (requires sudo password)..."
sudo make prefix=/usr/local install

echo ""
echo "Update complete!"
git --version

Save the file by pressing Ctrl+O, then Enter, then exit with Ctrl+X. Next, make the script executable:

chmod +x ~/update-git.sh

Run the script whenever you want to update Git:

~/update-git.sh

When you run the script, you will see output similar to the following:

Checking for latest Git version...
Current installed version: git version 2.49.0
Latest available version: Git v2.52.0

Continue with update? (y/n) y

Downloading Git v2.52.0...
Extracting source code...
Compiling Git (this may take a few minutes)...
Installing Git (requires sudo password)...
[sudo] password for user: 

Update complete!
git version 2.52.0

The script shows your current version and the latest available version, asks for confirmation before proceeding, and displays progress messages throughout the update process. Your Git configuration at ~/.gitconfig remains untouched.

Remove Git

To uninstall Git, the process depends on your installation method.

For installations from the default repository:

sudo apt remove git

For users who installed Git from the PPA, first remove the package, then remove the repository:

sudo apt remove git

Then remove the PPA repositories:

sudo add-apt-repository --remove ppa:git-core/ppa -y
sudo add-apt-repository --remove ppa:git-core/candidate -y

For source-compiled installations, remove the Git binaries and supporting files from /usr/local:

Warning: The following command permanently deletes the source-compiled Git installation. If you have customized your Git configuration at ~/.gitconfig, that file remains untouched and will work with any future Git installation.

sudo rm -rf /usr/local/bin/git* /usr/local/share/git-core /usr/local/libexec/git-core

If you installed both a source-compiled version and an APT package, the source version in /usr/local/bin takes precedence. After removing the source installation, verify which Git version remains active by running which git and git --version. The system will now use the APT-installed version from /usr/bin if one exists, or report that Git is not found if no package remains.

Conclusion

You now have a production-ready Git installation on Linux Mint with identity configuration, SSH authentication for remote repositories, and knowledge of core workflow commands including initialization, staging, committing, branching, and pushing changes. Whether you chose the stable default repository, the latest PPA version, or a custom source build, you can manage code history, collaborate on shared projects, and resolve common issues like authentication failures or version conflicts. For a graphical interface, consider installing GitHub Desktop on Linux Mint. Developers working with code editors may also want to set up VS Code or VSCodium, both of which integrate directly with Git for inline diffs, staging, and branch management. If you are building development environments, you might also explore Android Studio on Linux Mint for mobile app version control workflows.

Leave a Comment

Let us know you are human: