How to Install Git on Linux Mint 21.x or 20.x
If you’re stuck on an older version of Git that can’t handle the latest SSH key format, this quick walk‑through will get the newest package from the official Mint repositories in a few minutes.
Prerequisites: Make sure your system is up to date
Before pulling any packages you should bump the package lists and upgrade what’s already installed.
If you skip this, you’ll end up with a half‑baked dependency tree that can break later steps.
sudo apt update && sudo apt upgrade -y
apt update grabs fresh metadata from all enabled sources; upgrade -y automatically pulls in any new dependencies without asking.
Step 1: Install Git with apt‑get
Mint’s default repositories ship a well‑tested build of Git.
Running the following will download and install it, along with any required libraries.
sudo apt install git -y
The -y flag tells APT to skip confirmation prompts—perfect for scripts or a quick fix after that nasty driver update I mentioned earlier.
Step 2: Verify the installation
Once the installer finishes, make sure you actually have Git and that it’s a recent enough version.
git --version
If you see something like git version 2.40.0, you’re good to go.
Older builds (e.g., 2.30.x) won’t support newer HTTPS certificates, which explains why my colleague was hitting “invalid certificate” errors when pushing to GitHub.
Optional: Set up your identity for commits
Git records the name and email address you use in every commit.
If these aren’t set, you’ll see warnings or, worse, your work will be attributed to a placeholder user.
git config --global user.name "Your Name" git config --global user.email "you@example.com"
The --global flag writes to ~/.gitconfig, so you only have to do this once per machine.
Troubleshooting common pitfalls
- “Could not resolve host” or “connection refused” errors – Usually means your DNS is misconfigured. Try flushing the cache:
sudo systemd-resolve --flush-caches
- Git complaining about missing ssh command – If you’re using SSH keys for authentication, make sure OpenSSH client is installed:
sudo apt install openssh-client
That’s all there is to it. Git should now be ready on your Mint machine. Happy coding (and may your commits finally go through without hiccups!).