Documentation Index Fetch the complete documentation index at: https://mintlify.com/shawal-mbalire/dotfiles/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This Git configuration uses the GitHub CLI (gh) for credential management, sets sensible defaults for performance and usability, and configures Neovim as the default editor.
Configuration Location
Main config: ~/.gitconfig (or ~/dot-gitconfig in dotfiles)
Credential Management
GitHub CLI handles authentication for GitHub and Gist:
[credential "https://github.com"]
helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[credential]
helper = !gh auth git-credential
Setting Up GitHub CLI
Install
Authenticate
Verify
Fedora: Ubuntu/Debian: macOS: Follow prompts to:
Choose GitHub.com or Enterprise
Select HTTPS or SSH
Authenticate via browser or token
Should show: ”✓ Logged in to github.com”
Why GitHub CLI?
No password prompts : Automatic token management
Two-factor auth : Handles 2FA seamlessly
Multiple accounts : Switch between accounts with gh auth switch
SSH key management : gh ssh-key commands
User Configuration
[user]
name = shawal-mbalire
email = mbalireshawal@gmail.com
Update with your information:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Editor Configuration
Sets Neovim as the default editor for commit messages, interactive rebases, etc.
Alternative Editors
# Vim
git config --global core.editor vim
# VS Code
git config --global core.editor "code --wait"
# Nano
git config --global core.editor nano
HTTP Configuration
[http]
postBuffer = 524288000 # 500 MB buffer
version = HTTP/1.1
lowSpeedLimit = 0
lowSpeedTime = 999999
postBuffer : Increases buffer for large repositories (500 MB)
HTTP/1.1 : Uses HTTP/1.1 for better compatibility
lowSpeed settings : Prevents timeout on slow connections
Useful for:
Large repositories with big binary files
Slow or unstable network connections
Pushing large commits
Repository Initialization
[init]
defaultBranch = main
Sets main as the default branch for new repositories (instead of master).
Useful Aliases
Add to ~/.gitconfig for productivity:
[alias]
# Status
s = status -s
st = status
# Commit
c = commit
cm = commit -m
ca = commit --amend
# Branch
b = branch
ba = branch -a
bd = branch -d
# Checkout
co = checkout
cob = checkout -b
# Log
l = log --oneline
lg = log --graph --oneline --decorate --all
last = log -1 HEAD
# Diff
d = diff
ds = diff --staged
# Remote
p = push
pl = pull
f = fetch
# Reset
unstage = reset HEAD --
undo = reset --soft HEAD^
# Stash
ss = stash save
sl = stash list
sp = stash pop
Using Aliases
git s # Short status
git cm "msg" # Commit with message
git lg # Pretty log graph
git cob feat # Create and checkout branch
git undo # Undo last commit (keep changes)
Additional Recommended Settings
Auto-correct Typos
[help]
autocorrect = 20 # Wait 2 seconds before auto-executing
Example:
$ git pussh
WARNING: You called a Git command named 'pussh', which does not exist.
Continuing in 2 seconds, assuming you meant 'push'.
Color Output
[color]
ui = auto
branch = auto
diff = auto
status = auto
Rebase by Default
Use git pull --rebase by default for cleaner history.
Default Push Behavior
[push]
default = current
autoSetupRemote = true
Pushes current branch to remote with same name
Automatically sets up remote tracking
[merge]
tool = vimdiff
conflictstyle = diff3
Or use Neovim:
[merge]
tool = nvim
[mergetool "nvim"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
SSH Configuration
Prefer SSH over HTTPS:
# Generate SSH key
ssh-keygen -t ed25519 -C "your.email@example.com"
# Add to GitHub
gh ssh-key add ~/.ssh/id_ed25519.pub
# Or manually at https://github.com/settings/keys
Always Use SSH
[url "git@github.com:"]
insteadOf = https://github.com/
Automatically converts HTTPS URLs to SSH.
Per-Repository Configuration
Override global settings in specific repos:
cd ~/work/repo
git config user.email "work@company.com"
git config core.editor "code --wait"
Settings stored in .git/config (not ~/.gitconfig).
FAQ
Check GitHub CLI status: If logged out: Refresh credentials:
Increase HTTP buffer: [http]
postBuffer = 1048576000 # 1 GB
Or switch to SSH: git remote set-url origin git@github.com:user/repo.git
How do I use different email for work repos?
Use conditional includes: # ~/.gitconfig
[includeIf "gitdir:~/work/"]
path = ~/.gitconfig-work
Create ~/.gitconfig-work: [user]
email = work@company.com
How to sign commits with GPG?
Generate GPG key: Add to GitHub: Configure Git: git config --global user.signingkey YOUR_GPG_KEY_ID
git config --global commit.gpgsign true
Default branch still 'master'?
Set globally: git config --global init.defaultBranch main
Rename existing branch: git branch -m master main
git push -u origin main
git push origin --delete master
Complete Example Configuration
# ~/.gitconfig
[user]
name = Your Name
email = your.email@example.com
[core]
editor = nvim
autocrlf = input
excludesfile = ~/.gitignore_global
[init]
defaultBranch = main
[credential]
helper = !gh auth git-credential
[credential "https://github.com"]
helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[http]
postBuffer = 524288000
version = HTTP/1.1
[pull]
rebase = true
[push]
default = current
autoSetupRemote = true
[color]
ui = auto
[alias]
s = status -s
cm = commit -m
co = checkout
cob = checkout -b
l = log --oneline
lg = log --graph --oneline --decorate --all
unstage = reset HEAD --
undo = reset --soft HEAD^
Global Gitignore
Create ~/.gitignore_global:
# OS Files
.DS_Store
Thumbs.db
# Editor
.vscode/
.idea/
*.swp
*.swo
*~
# Dependencies
node_modules/
vendor/
# Build
dist/
build/
*.log
Enable:
git config --global core.excludesfile ~/.gitignore_global