Most Fedora development workflows need Git before anything else: cloning a project, tracking local changes, checking out branches, or pushing work to GitHub, GitLab, and other remotes. The quickest way to install Git on Fedora is the distro package, which currently tracks the same stable 2.54.x line as upstream for Fedora 44 and Fedora 43.
Use DNF unless you have a specific reason to compile Git yourself. The source-build path is included for custom patches, build options, or a pinned upstream release, but it adds manual maintenance and places the active binary under /usr/local/bin through a versioned /usr/local/git-<version> prefix.
Install Git on Fedora
Start by refreshing Fedora package metadata and applying available updates. This reduces dependency conflicts before installing developer tools:
sudo dnf upgrade --refresh
Two installation paths are practical on Fedora. The DNF package is the right choice for almost everyone because Fedora handles security and maintenance updates through the normal package workflow.
| Method | Source or Channel | Update Behavior | Best For | Trade-offs |
|---|---|---|---|---|
| DNF package | Fedora package | Updates with dnf upgrade | Daily development, servers, and most workstations | Follows Fedora’s package cadence |
| Source build | Git source tarballs | Manual rebuild or helper script | Custom patches, build options, or a pinned release | More maintenance; /usr/local/bin/git can override the DNF binary |
Use one method unless you deliberately want both. A source build installed to
/usr/localnormally wins over Fedora’s/usr/bin/giton yourPATH. If you mix methods, check the active binary withcommand -v gitbefore troubleshooting version or behavior differences.
Install Git with DNF on Fedora
Fedora packages Git in the standard repositories, so the managed install is one command:
sudo dnf install git
Verify the installed command path and version:
command -v git
git --version
Example output from the current Fedora package:
/usr/bin/git git version 2.54.0
Your version can be newer after Fedora publishes updates. The important part is that
command -v gitpoints to/usr/bin/gitfor the DNF package path.
Compile Git from Source on Fedora
Compile Git only when the Fedora package does not match your requirement. The build below uses the latest stable upstream source release, installs under /usr/local, and leaves Fedora’s RPM database untouched.
Install Git Source Build Dependencies
Install the compiler, build tools, JSON parser, GnuPG verifier, and development headers Git needs for HTTPS, TLS, compression, localization, and Perl helper scripts:
sudo dnf install gcc make curl jq tar gzip gnupg2 libcurl-devel expat-devel openssl-devel zlib-devel gettext-devel perl-ExtUtils-MakeMaker
The download flow uses Git’s official source page, kernel.org tarballs, and detached GPG signatures. It also uses the curl command in Linux for the source and release-key requests.
Create a Git Source Workspace
Create a stable user-owned workspace for the source archive, signature, and extracted build tree:
BUILD_DIR="$HOME/git-source-build"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
Resolve the Current Git Source Version
Read the current source version from Git’s official source-install page and print it before downloading anything:
VERSION=$(curl -fsSL https://git-scm.com/install/source.html | grep -oE 'git-[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' | sed -E 's/git-([0-9.]+)\.tar\.gz/\1/' | head -n 1)
test -n "$VERSION" || { echo "Could not detect the latest Git source version."; exit 1; }
printf '%s\n' "$VERSION"
Current output is:
2.54.0
Import the Git Release Signing Key
Import Junio C Hamano’s Git release signing key from the junio-gpg-pub object in Git’s official GitHub mirror, then confirm the primary fingerprint:
TAG_OBJECT_URL=$(curl -fsSL https://api.github.com/repos/git/git/git/ref/tags/junio-gpg-pub | jq -r '.object.url')
KEY_BLOB_URL=$(curl -fsSL "$TAG_OBJECT_URL" | jq -r '.object.url')
curl -fsSL "$KEY_BLOB_URL" | jq -r '.content' | base64 -d > git-maintainer-key.asc
gpg --import git-maintainer-key.asc
gpg --fingerprint 96E07AF25771955980DAD10020D04E5A713660A7
Relevant output includes the primary key fingerprint:
pub rsa4096 2011-10-01 [SC]
96E0 7AF2 5771 9559 80DA D100 20D0 4E5A 7136 60A7
uid [ unknown] Junio C Hamano <gitster@pobox.com>
Download and Verify Git Source
Download the matching kernel.org source archive and detached signature:
curl -fLO --progress-bar "https://www.kernel.org/pub/software/scm/git/git-${VERSION}.tar.gz"
curl -fLO --progress-bar "https://www.kernel.org/pub/software/scm/git/git-${VERSION}.tar.sign"
The signature applies to the uncompressed tar stream, so verify it through gzip -cd:
gzip -cd "git-${VERSION}.tar.gz" | gpg --verify "git-${VERSION}.tar.sign" -
Relevant output includes the good signature and matching fingerprints. GnuPG may still warn that the key is not certified by your personal trust chain; that warning is normal unless you have assigned owner trust to the key yourself.
gpg: Good signature from "Junio C Hamano <gitster@pobox.com>" [unknown]
Primary key fingerprint: 96E0 7AF2 5771 9559 80DA D100 20D0 4E5A 7136 60A7
Subkey fingerprint: E1F0 36B1 FEE7 221F C778 ECEF B0B5 E886 96AF E6CB
Extract Git Source
Extract the verified archive into a clean source tree under the workspace:
rm -rf "$BUILD_DIR/src"
mkdir -p "$BUILD_DIR/src"
tar -xzf "git-${VERSION}.tar.gz" -C "$BUILD_DIR/src" --strip-components=1
cd "$BUILD_DIR/src"
test -f Makefile && printf 'Git source ready: %s\n' "$VERSION"
Git source ready: 2.54.0
Compile and Install Source-Built Git
Build Git with Fedora’s available CPU cores. The compile step prints many CC, LINK, and GEN lines while it works:
make prefix="/usr/local/git-${VERSION}" all -j"$(nproc)"
Install the compiled files into a versioned prefix, then point stable symlinks at that prefix:
sudo make prefix="/usr/local/git-${VERSION}" install
sudo ln -sfn "/usr/local/git-${VERSION}" /usr/local/git-current
for tool in git gitk scalar git-cvsserver git-shell git-upload-pack git-receive-pack git-upload-archive; do
if [ -x "/usr/local/git-current/bin/$tool" ]; then
sudo ln -sfn "/usr/local/git-current/bin/$tool" "/usr/local/bin/$tool"
fi
done
Refresh the shell’s command cache, then verify that the source-built binary is active:
hash -r
command -v git
git --version
git --exec-path
Expected output for the source build looks like this:
/usr/local/bin/git git version 2.54.0 /usr/local/git-2.54.0/libexec/git-core
Configure Git on Fedora
After installation, configure your commit identity before creating repositories. Git stores these values in your global config and writes them into future commits unless a repository overrides them.
Set Your Git Identity and Default Branch
Set your name, email address, and preferred default branch for new repositories:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
Git still defaults to master when init.defaultBranch is unset, so the last command keeps new local repositories aligned with GitHub’s common main branch naming. For more identity examples, use Configure Git Username and Email.
Verify the saved values:
git config --global --get-regexp '^(user.name|user.email|init.defaultBranch)$'
user.name Your Name user.email you@example.com init.defaultBranch main
Create a First Git Repository on Fedora
Create a small test project and initialize it as a Git repository:
mkdir -p ~/my-project
cd ~/my-project
git init
Example output after setting init.defaultBranch to main:
Initialized empty Git repository in /home/user/my-project/.git/
Check the branch and repository state:
git status --short --branch
## No commits yet on main
Make Your First Git Commit
Create a file, stage it, and commit it to the local repository:
printf 'hello from Fedora\n' > README.md
git add README.md
git commit -m "Add README"
The commit command prints a short summary with a generated commit hash, the branch name, and the changed file count. If you commit too early or use the wrong message, Undo Last Git Commit explains the safer reset and revert choices.
Connect Git to a Remote Repository
Add a remote URL after creating the matching empty repository on GitHub, GitLab, or your own Git server. Replace the example path with your account and repository name:
git remote add origin git@github.com:username/repository.git
git push -u origin main
SSH remotes avoid repeated HTTPS credential prompts once your key is configured. If you still need to set up the server side of SSH, follow Enable SSH on Fedora before relying on Git over SSH.
Cache HTTPS Git Credentials
HTTPS remotes usually require a personal access token or a hosting-service credential flow instead of your account password. Fedora’s Git package can cache approved HTTPS credentials in memory for a short session:
git config --global credential.helper cache
The default timeout is 15 minutes. Set a longer timeout in seconds when you want credentials to remain available during a longer work session:
git config --global credential.helper "cache --timeout=18000"
Troubleshoot Git on Fedora
Most Git failures after installation come from identity, remote URL, credential, certificate, proxy, or SSH key state rather than the package itself.
Git Uses the Wrong Binary on Fedora
If Git reports an unexpected version after mixing DNF and source builds, check which binary your shell finds first:
command -v git
git --version
DNF-installed Git normally resolves to /usr/bin/git. A source build installed with this article resolves to /usr/local/bin/git. Remove the source build or adjust your PATH if you want Fedora’s package to take priority again.
Repository URL Not Found
A clone or push can fail when the remote URL points only to the hosting domain or to a repository that does not exist:
fatal: repository 'https://github.com/' not found
Check the saved remote URL inside the repository:
git remote -v
Replace the remote with the full repository URL:
git remote set-url origin git@github.com:username/repository.git
Permission Denied When Pushing with SSH
SSH authentication failures usually look like this:
git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
List keys currently loaded in your SSH agent:
ssh-add -l
If your key is missing, add it and then confirm the public key is registered with your Git hosting account:
ssh-add ~/.ssh/id_ed25519
The Fedora SSH setup path is covered in Enable SSH on Fedora.
SSL Certificate Errors with Git
Certificate trust failures usually mention the local issuer or an unknown authority:
SSL certificate problem: unable to get local issuer certificate
Refresh Fedora’s CA certificate package first:
sudo dnf upgrade ca-certificates
For a corporate proxy or private certificate authority, point Git at the CA certificate your organization provides:
git config --global http.sslCAInfo /path/to/your/certificate.crt
Do not make
http.sslVerify=falsea permanent fix. Disabling TLS verification lets an attacker or broken proxy impersonate the remote Git server.
Git Behind a Proxy on Fedora
Set Git proxy values only when your network requires them:
git config --global http.proxy http://proxy.example.com:8080
git config --global https.proxy http://proxy.example.com:8080
Remove the proxy settings when you leave that network:
git config --global --unset http.proxy
git config --global --unset https.proxy
Update or Remove Git on Fedora
Update and removal steps depend on which installation method owns the active Git binary.
Update DNF-Installed Git on Fedora
When Git came from Fedora’s package repositories, update it with the rest of your system or target the package directly:
sudo dnf upgrade --refresh git
If DNF reports Nothing to do., your enabled repositories do not currently offer a newer Git package.
Update Source-Compiled Git on Fedora
A source install under /usr/local does not receive DNF updates. Create a reusable helper that checks Git’s official source page, verifies the matching kernel.org signature, rebuilds Git when needed, and updates the /usr/local/git-current symlink after a successful install:
sudo tee /usr/local/bin/update-git-source >/dev/null <<'SCRIPT_EOF'
#!/usr/bin/env bash
set -euo pipefail
PRIMARY_FPR="96E07AF25771955980DAD10020D04E5A713660A7"
BASE_PREFIX="/usr/local"
BUILD_DIR="$HOME/git-source-build"
SRC_DIR="$BUILD_DIR/src"
if [ "$(id -u)" -eq 0 ]; then
echo "Run this script as your regular user; it uses sudo only for the install step."
exit 1
fi
for cmd in base64 curl gpg grep gzip jq make sed tar; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: $cmd is required. Install the source-build dependencies first."
exit 1
fi
done
if [ -n "${1:-}" ]; then
LATEST_VERSION="${1#v}"
else
LATEST_VERSION=$(curl -fsSL https://git-scm.com/install/source.html | grep -oE 'git-[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' | sed -E 's/git-([0-9.]+)\.tar\.gz/\1/' | head -n 1)
fi
if ! [[ "$LATEST_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: could not detect a stable Git source version."
exit 1
fi
CURRENT_VERSION="$("$BASE_PREFIX/git-current/bin/git" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1 || true)"
CURRENT_VERSION="${CURRENT_VERSION:-none}"
echo "Current source Git version: $CURRENT_VERSION"
echo "Latest Git version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "Already up to date."
exit 0
fi
if ! command -v gcc >/dev/null 2>&1; then
echo "Error: gcc is required. Install the source-build dependencies first."
exit 1
fi
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
if ! gpg --list-keys "$PRIMARY_FPR" >/dev/null 2>&1; then
echo "Importing Git release signing key..."
TAG_OBJECT_URL=$(curl -fsSL https://api.github.com/repos/git/git/git/ref/tags/junio-gpg-pub | jq -r '.object.url')
KEY_BLOB_URL=$(curl -fsSL "$TAG_OBJECT_URL" | jq -r '.object.url')
curl -fsSL "$KEY_BLOB_URL" | jq -r '.content' | base64 -d >git-maintainer-key.asc
gpg --import git-maintainer-key.asc
fi
echo "Downloading Git $LATEST_VERSION..."
curl -fLO --progress-bar "https://www.kernel.org/pub/software/scm/git/git-${LATEST_VERSION}.tar.gz"
curl -fLO --progress-bar "https://www.kernel.org/pub/software/scm/git/git-${LATEST_VERSION}.tar.sign"
echo "Verifying signature..."
gzip -cd "git-${LATEST_VERSION}.tar.gz" | gpg --verify "git-${LATEST_VERSION}.tar.sign" -
echo "Extracting source..."
rm -rf "$SRC_DIR"
mkdir -p "$SRC_DIR"
tar -xzf "git-${LATEST_VERSION}.tar.gz" -C "$SRC_DIR" --strip-components=1
cd "$SRC_DIR"
echo "Compiling Git..."
NEW_PREFIX="$BASE_PREFIX/git-$LATEST_VERSION"
OLD_PREFIX="$(readlink -f "$BASE_PREFIX/git-current" 2>/dev/null || true)"
make prefix="$NEW_PREFIX" all -j"$(nproc)"
echo "Installing Git to $NEW_PREFIX..."
sudo make prefix="$NEW_PREFIX" install
sudo ln -sfn "$NEW_PREFIX" "$BASE_PREFIX/git-current"
for tool in git gitk scalar git-cvsserver git-shell git-upload-pack git-receive-pack git-upload-archive; do
if [ -x "$BASE_PREFIX/git-current/bin/$tool" ]; then
sudo ln -sfn "$BASE_PREFIX/git-current/bin/$tool" "$BASE_PREFIX/bin/$tool"
fi
done
if [ -n "$OLD_PREFIX" ] && [ "$OLD_PREFIX" != "$NEW_PREFIX" ] && [[ "$OLD_PREFIX" == "$BASE_PREFIX"/git-[0-9]* ]]; then
sudo rm -rf "$OLD_PREFIX"
fi
hash -r
"$BASE_PREFIX/bin/git" --version
echo "Source Git update complete."
SCRIPT_EOF
sudo chmod 0755 /usr/local/bin/update-git-source
Confirm the helper is on your PATH:
command -v update-git-source
/usr/local/bin/update-git-source
Run the helper manually when you want to check for a source-build update. To rebuild the exact release validated here, pass the version explicitly as update-git-source 2.54.0.
update-git-source
Example output when your source build already matches the latest source release:
Current source Git version: 2.54.0 Latest Git version: 2.54.0 Already up to date.
Avoid running source-build updates from cron. Compilation can fail because of dependency changes, network failures, or upstream build changes, and you should see that output before a system-wide Git binary is replaced.
Remove DNF-Installed Git on Fedora
Remove the Fedora package when Git was installed with DNF:
sudo dnf remove git
DNF may also remove unused Git and Perl dependencies. Review the transaction before confirming on systems where other development tools depend on Git.
Check the installed package state after removal:
rpm -q git git-core || true
package git is not installed package git-core is not installed
Remove Source-Compiled Git on Fedora
Source-compiled Git installs outside RPM tracking, so DNF cannot remove it. Check the active binary and managed prefix before deleting files:
command -v git
git --exec-path
readlink -f /usr/local/git-current 2>/dev/null || true
The next commands delete the versioned Git prefix, stable symlinks, source workspace, and update helper created in this article. Do not run them if
/usr/local/git-currentpoints to a custom Git installation you manage another way.
SOURCE_PREFIX=$(readlink -f /usr/local/git-current 2>/dev/null || true)
case "$SOURCE_PREFIX" in
/usr/local/git-[0-9]*)
sudo rm -f /usr/local/bin/git /usr/local/bin/gitk /usr/local/bin/scalar
sudo rm -f /usr/local/bin/git-cvsserver /usr/local/bin/git-shell
sudo rm -f /usr/local/bin/git-upload-pack /usr/local/bin/git-receive-pack /usr/local/bin/git-upload-archive
sudo rm -f /usr/local/git-current
sudo rm -rf "$SOURCE_PREFIX"
;;
*)
echo "No article-managed source Git prefix found."
;;
esac
sudo rm -f /usr/local/bin/update-git-source
rm -rf "$HOME/git-source-build"
Refresh the shell command cache and check what Git resolves to afterward:
hash -r
command -v git || echo "git command is not available"
If Fedora’s DNF package is still installed, the command should return /usr/bin/git. If no Git package remains, it should print git command is not available.
Remove Git User Configuration
Package removal does not delete your commit identity, aliases, or saved credential files. Remove them only when you want to reset Git for the current Linux user:
The next command deletes your global Git config and any stored plaintext credential file for this account. Back up
~/.gitconfigfirst if you need aliases, signing settings, or identity values later.
git credential-cache exit 2>/dev/null || true
rm -f ~/.gitconfig ~/.git-credentials
Conclusion
Git is ready on Fedora through the managed DNF package or a source build managed by /usr/local/git-current, with commit identity, branch naming, and remote access prepared for normal development work. For GUI repository management, pair it with Install GitHub Desktop on Fedora; for editor-integrated Git workflows, use Install Visual Studio Code on Fedora.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>