Setting Up Git on Modern Linux (SSH Signing, Ed25519 & Best Practices)

2 min read

A standard, clean Git configuration ensures cryptographic commit integrity, consistent line endings across platforms, and streamlined branching workflows.

1. Global Identity & Default Branch

Modern Git uses main as the standard default branch name:

⚡ Quick Runbook: 60-Second Implementation

TL;DR: Copy and deploy the baseline production definition directly onto your host:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main

2. Generate an Ed25519 SSH Key

For authenticating with remote repositories (GitHub, GitLab, Forgejo), use an Ed25519 key with 100 key-derivation function rounds for enhanced resistance to offline dictionary attacks:

ssh-keygen -t ed25519 -a 100 -C "[email protected]" -f ~/.ssh/id_ed25519

Add your SSH agent configuration to ~/.ssh/config:

Host github.com gitlab.com
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes
    AddKeysToAgent yes

3. Cryptographic Commit Signing with SSH Keys

Instead of configuring complex GPG keys, Git supports native commit signing using your existing SSH key:

# Configure Git to use SSH for signing
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub

# Automatically sign all commits
git config --global commit.gpgsign true
git config --global tag.gpgSign true

4. Essential Ergonomic Aliases & Diff Settings

# Faster branch status and graph history
git config --global alias.st "status -sb"
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

# Sensible pull behavior (avoid accidental merge commits)
git config --global pull.rebase true

# Sensible diff colors
git config --global color.ui auto

Related Runbooks in This Series

Tags:

← Previous:
Next: →