How to Install Git on Arch Linux

Last updated Saturday, February 7, 2026 6:38 pm 9 min read

Git is the distributed version control system created by Linus Torvalds for tracking changes in source code during software development. Whether you contribute to open-source projects, manage configuration files, or maintain personal codebases, Git handles branching, merging, and collaboration while preserving a complete history of every change. This guide covers how to install Git on Arch Linux using the official repositories, configure it for first-time use, set up SSH authentication for remote repositories, and remove Git when no longer needed.

Update Arch Linux Before Installing Git

Synchronize the package database and upgrade all installed packages before installing new software. This prevents dependency conflicts and ensures you receive the latest available version of Git:

sudo pacman -Syu

If you have not yet configured a sudo user on Arch Linux, see how to add and manage sudo users on Arch Linux before proceeding.

Install Git on Arch Linux

The git package is available in the official Arch Linux extra repository. Install it with pacman:

sudo pacman -S git

This installs the complete Git toolset including the command-line client, merge tools, and support for protocols like HTTP, HTTPS, and SSH. The package also provides git-gui and gitk when you install the optional tk dependency.

Verify the Git Installation

Confirm Git is installed and check the version number:

git --version

Example output:

git version 2.53.0

Your version number reflects the current Arch Linux package. Since Arch uses a rolling release model, you always receive the latest stable Git release through regular system updates.

Configure Git on Arch Linux

Git requires a username and email address before you can create commits. These values appear in every commit you make and identify you as the author.

Set Your Git Username and Email

Configure your global identity that applies to all repositories on your system:

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

Replace Your Name and your_email@example.com with your actual name and the email address associated with your Git hosting account (GitHub, GitLab, or similar).

Set the Default Branch Name

Modern Git repositories use main as the default branch name. Configure this to avoid the hint: Using 'master' as the name for the initial branch message when creating new repositories:

git config --global init.defaultBranch main

Set the Default Text Editor

Git opens a text editor for commit messages, interactive rebase operations, and merge conflict resolution. Set your preferred editor:

git config --global core.editor "nano"

Replace nano with vim, code --wait (for VS Code), or any other editor you prefer.

Verify Your Git Configuration

Review all global configuration settings to confirm your changes:

git config --list --global

Expected output:

user.name=Your Name
user.email=your_email@example.com
init.defaultbranch=main
core.editor=nano

Git stores global configuration in ~/.gitconfig. You can edit this file directly or use repository-specific settings with git config --local inside any Git repository to override global values for individual projects.

Set Up SSH Authentication for Git on Arch Linux

SSH keys provide secure, passwordless authentication when pushing to and pulling from remote Git repositories on platforms like GitHub and GitLab. This eliminates repeated password prompts and is more secure than HTTPS token-based authentication.

Install OpenSSH

Arch Linux does not install OpenSSH by default. If you have not already installed it, the openssh package provides the SSH client and key generation tools that Git uses for SSH transport:

sudo pacman -S openssh

For a complete walkthrough of SSH configuration including server setup and security hardening, see how to install OpenSSH on Arch Linux.

Generate an SSH Key Pair

Create a new ED25519 key pair for Git authentication:

ssh-keygen -t ed25519 -C "your_email@example.com"

Press Enter to accept the default file location (~/.ssh/id_ed25519) and optionally set a passphrase for additional security:

Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/username/.ssh/id_ed25519): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/username/.ssh/id_ed25519
Your public key has been saved in /home/username/.ssh/id_ed25519.pub

Add Your SSH Key to the Agent

Start the SSH agent and add your private key so you do not have to enter the passphrase repeatedly:

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_ed25519

Copy the Public Key

Display your public key to copy it to your Git hosting provider (GitHub, GitLab, or similar):

cat ~/.ssh/id_ed25519.pub

Copy the entire output and add it to your account’s SSH key settings on your Git hosting platform. For GitHub, navigate to Settings, then SSH and GPG keys, then New SSH key.

Test SSH Authentication

Verify your SSH key works with GitHub:

ssh -T git@github.com

Expected output on successful authentication:

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

For GitLab, use ssh -T git@gitlab.com instead.

Basic Git Commands on Arch Linux

These essential commands cover the daily Git workflow for creating repositories, tracking changes, and collaborating with remote repositories.

Initialize a New Repository

Create a new Git repository in the current directory:

mkdir ~/my-project && cd ~/my-project
git init

Expected output:

Initialized empty Git repository in /home/username/my-project/.git/

Clone an Existing Repository

Download a remote repository to your local machine:

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

For HTTPS cloning (when SSH is not configured):

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

Stage and Commit Changes

Track file changes and record them in the repository history. Stage all modified and new files, then commit with a descriptive message:

git add .
git commit -m "Add initial project files"

To stage specific files instead of everything, replace the period with the file path: git add filename.txt.

Push Changes to a Remote Repository

Upload your local commits to the remote repository:

git push origin main

Pull Changes from a Remote Repository

Download and merge remote changes into your local branch:

git pull origin main

Check Repository Status and History

View the current state of your working directory and staging area:

git status

View the commit history with a compact, graphical representation:

git log --oneline --graph --decorate

For more Git operations including renaming Git branches, undoing Git commits, and clearing the Git cache, see the linked guides.

Enable Git Bash Completion on Arch Linux

Bash completion allows you to press Tab to autocomplete Git commands, branch names, and remote references, which speeds up your workflow and reduces typing errors.

Install Bash Completion

The Git package includes completion scripts, but you need the bash-completion framework to enable them:

sudo pacman -S bash-completion

After installation, start a new terminal session or source the completion script manually:

source /usr/share/git/completion/git-completion.bash

To load Git completion permanently, add the source line to your ~/.bashrc file. If you use Zsh, Git completion loads automatically through the Zsh completion system.

Enable Git Prompt Information

Display the current branch name and repository state directly in your shell prompt. Source the Git prompt script and update your PS1 variable:

source /usr/share/git/completion/git-prompt.sh
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '

Add both lines to your ~/.bashrc to make the prompt change persistent. When you enter a Git repository, the prompt displays the current branch name in parentheses.

Troubleshoot Git on Arch Linux

These are the most common issues encountered when using Git on Arch Linux and how to resolve them.

Fatal: Not a Git Repository

This error appears when running Git commands outside a repository or in a directory that has not been initialized:

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

Verify you are in the correct directory, then initialize or clone a repository:

pwd
git init

Permission Denied (Publickey) When Pushing

SSH authentication failures produce this error when pushing to remote repositories:

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

Verify your SSH key is loaded and test the connection:

ssh-add -l
ssh -T git@github.com

If no keys are listed, add your key to the SSH agent:

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_ed25519

Also confirm your public key is added to your Git hosting account’s SSH key settings.

Author Identity Unknown Error

Git refuses to create commits without configured user information:

Author identity unknown
*** Please tell me who you are.

Set your identity as described in the configuration section:

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

SSL Certificate Problem When Cloning

Corporate proxies or outdated CA certificates can cause HTTPS clone failures:

fatal: unable to access 'https://github.com/...': SSL certificate problem: unable to get local issuer certificate

Update the CA certificates package:

sudo pacman -S ca-certificates

If you are behind a corporate proxy that replaces SSL certificates, configure Git to use the proxy’s CA bundle:

git config --global http.sslCAInfo /path/to/corporate-ca-bundle.crt

Never disable SSL verification globally with git config --global http.sslVerify false. This exposes all Git traffic to man-in-the-middle attacks. If you must bypass verification, limit it to a single repository using git config --local http.sslVerify false and only as a temporary measure.

Remove Git from Arch Linux

If you no longer need Git, remove the package along with its configuration files and unused dependencies.

Uninstall the Git Package

Remove Git and all orphaned dependencies:

sudo pacman -Rns git

The -Rns flags perform a complete removal: -R removes the package, -n (nosave) deletes configuration files instead of creating .pacsave backups, and -s (recursive) removes dependencies that are no longer required by other packages.

Verify Git Removal

Confirm Git is no longer installed:

git --version

Expected output:

bash: git: command not found

Removing the git package does not delete your user-level Git configuration (~/.gitconfig) or any local repositories. To remove the global configuration file, run rm ~/.gitconfig. Local repositories in project directories remain intact and can be reused after reinstalling Git.

Common Questions About Git on Arch Linux

Is Git installed by default on Arch Linux?

No. Arch Linux follows a minimal installation philosophy. Git is not included in the base installation and must be installed manually using sudo pacman -S git from the official extra repository.

How do I update Git on Arch Linux?

Run sudo pacman -Syu to update all system packages including Git. Arch Linux is a rolling release distribution, so Git updates arrive automatically through regular system upgrades without requiring separate commands.

What is the difference between git config –global and –local?

The --global flag sets configuration for all repositories under your user account and stores values in ~/.gitconfig. The --local flag applies settings only to the current repository, stored in the .git/config file within that project directory. Local settings override global settings.

Should I use SSH or HTTPS for Git remote connections?

SSH is generally preferred because it provides key-based authentication without requiring password or token entry for every push. HTTPS is simpler to set up initially and works through firewalls that block SSH, but requires credential helpers or personal access tokens for authentication.

Conclusion

You now have Git installed and configured on Arch Linux. Installing with sudo pacman -S git, setting your identity with git config --global, and configuring SSH authentication provide the foundation for version-controlled development. System updates through sudo pacman -Syu automatically deliver new Git releases on this rolling distribution, so no manual upgrade steps are necessary. For detailed reference on Git internals and advanced workflows, consult the Arch Wiki Git page and the Pro Git book.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Leave a Comment

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: