Home DevOps Git Config and Aliases — The 'git st' That Staged Everything
Beginner 3 min · July 07, 2026

Git Config and Aliases — The 'git st' That Staged Everything

A developer aliased 'git st' to 'status' but their colleague's 'git st' ran 'add .'.

N
Naren Founder & Principal Engineer

20+ years shipping production infrastructure and CI/CD at scale. Everything here is grounded in real deployments.

Follow
Production
production tested
July 07, 2026
last updated
214
articles · all by Naren
Before you start⏱ 15 min
  • Basic programming fundamentals (variables, functions, control flow)
  • No prior devops experience needed — we start from first principles
 ● Production Incident
Quick Answer

Set user info: git config --global user.name 'Name'. Create aliases: git config --global alias.st statusgit st runs status. Config levels: --system (all users), --global (your account), --local (current repo).

✦ Definition~90s read
What is Git Config and Aliases?

Git config controls Git's behavior at system, global, and local levels. Git aliases create custom shorthand commands. Together they customize Git to match your workflow.

Git config is like a settings menu where you customize how Git behaves.
Plain-English First

Git config is like a settings menu where you customize how Git behaves. Git aliases let you create keyboard shortcuts for your most-used commands. git config --global alias.co checkout means instead of typing git checkout, you type git co. It's like creating text shortcuts on your phone — 'omw' expands to 'on my way'. Git aliases expand to full commands.

Git aliases are the #1 productivity hack for daily Git users. A well-crafted set of aliases reduces common 5-word commands to 2-3 characters. git co instead of git checkout, git br instead of git branch, git lg for a pretty log output. But aliases come with a trap: if you share aliases (e.g., via a team .gitconfig), different developers may have different interpretations of the same alias. This guide covers the essential aliases, the three config levels and when to use each, and the incident where a shared alias file caused unexpected staging behavior.

Essential Git Aliases for Daily Use

The most productive aliases reduce common 3-6 word commands to 2-3 characters:

  • co = checkoutgit co main instead of git checkout main
  • br = branchgit br -a instead of git branch -a
  • ci = commitgit ci -m 'message' instead of git commit -m 'message'
  • st = statusgit st instead of git status
  • lg = log --oneline --graph --decorate --all — pretty log
  • unstage = reset HEAD --git unstage file to unstage
  • last = log -1 HEAD — show last commit
  • amend = commit --amend --no-edit — quick amend
  • undo = reset --soft HEAD~1 — undo last commit

Set them: git config --global alias.lg "log --oneline --graph --decorate --all"

01_git_aliases.shBASH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Set essential aliases
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.lg 'log --oneline --graph --decorate --all'
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global alias.amend 'commit --amend --no-edit'
git config --global alias.undo 'reset --soft HEAD~1'

# View all aliases
git config --global --get-regexp alias

# Use them
git st  # instead of git status
git lg  # pretty log output

# Config levels
# --system: /etc/gitconfig (all users on machine)
# --global: ~/.gitconfig (your account)
# --local: .git/config (current repo)

# View config at each level
git config --system --list 2>/dev/null
git config --global --list
git config --local --list
Output
alias.co checkout
alias.br branch
alias.ci commit
alias.st status
alias.lg log --oneline --graph --decorate --all
On branch main
nothing to commit, working tree clean
* a1b2c3d (HEAD -> main) Latest commit
* b2c3d4e Previous commit
* c3d4e5f Initial commit
Use `!` for Shell Command Aliases
Prefix the alias value with ! to run a shell command instead of a git subcommand. Example: git config --global alias.remote '!git remote -v | head -5'. Or combine commands: git config --global alias.cleanup '!git branch --merged | grep -v "*" | xargs git branch -d'.
Production Insight
Keep aliases in ~/.gitconfig (global) for personal shortcuts. Use --local (.git/config) for project-specific aliases (e.g., a monorepo with custom commands). Never commit a .gitconfig to the repo that auto-overwrites developer settings. Instead, document suggested aliases in CONTRIBUTING.md and let developers opt in. For teams using VS Code, the GitLens extension provides many visual shortcuts that reduce the need for CLI aliases.
Key Takeaway
Git aliases speed up daily commands by 3-5x. Keep them in ~/.gitconfig (global). Use ! for shell command aliases. Don't share aliases via committed config files — document suggestions and let developers opt in.
● Production incidentPOST-MORTEMseverity: high

The Shared Alias File That Made 'git st' Run 'git add .'

Symptom
A team shared a .gitconfig file with aliases. One developer added st = status and another later added st = add . thinking it was an unused shortcut. The second alias overwrote the first. The entire team's 'git st' started staging everything instead of showing status.
Assumption
Developers assumed aliases were additive. They didn't realize that duplicate aliases overwrite — the last one wins.
Root cause
1. The team maintained a shared .gitconfig file committed to the repository. 2. Developer A added st = status. 3. Developer B added st = add . thinking nobody was using 'st' for status. 4. The team's bootstrap script sourced the shared config. 5. 'git st' now ran 'git add .' — staging all files. 6. Developers ran 'git st' to check status before committing and unknowingly staged everything. 7. Sensitive files (.env, API keys) were staged and nearly committed.
Fix
1. Immediately: removed the conflicting alias from the shared config file. 2. Each developer ran git config --global --unset alias.st to clear their local alias. 3. Set up an alias review process: any new alias must be discussed in the team channel. 4. Moved to a convention-based approach: git config --global alias.st status is standard, documented in the team README. 5. Added a CI check that warns if a shared .gitconfig has duplicate aliases.
Key lesson
  • Shared aliases must be carefully managed — duplicates silently overwrite.
  • Use a documented convention for aliases.
  • Less is more: start with 5 essential aliases.
  • Per-repo aliases (local config) are safer for team adjustments.
Production debug guideUse this when production is on fire3 entries
Symptom · 01
I want to create a shortcut for a common command
Fix
Run git config --global alias.<shortcut> '<command>'
Symptom · 02
I want to see all my current aliases
Fix
Run git config --global --get-regexp alias
Symptom · 03
I need different config per project
Fix
Use --local config (stored in .git/config) for per-repo settings

Key takeaways

1
Aliases reduce common 5-word commands to 2-3 characters
2
Set via git config --global alias.<name> '<command>'
3
Use --local for per-repo settings, --global for personal shortcuts
4
Don't auto-overwrite developer configs
document aliases in contributing guide
N
Naren Founder & Principal Engineer

20+ years shipping production infrastructure and CI/CD at scale. Everything here is grounded in real deployments.

Follow
Verified
production tested
July 07, 2026
last updated
214
articles · all by Naren
🔥

That's Git. Mark it forged?

3 min read · try the examples if you haven't

Previous
Branch Protection Rules: Secure Your Git Workflow
41 / 47 · Git
Next
Git Diff: Spot Changes Before They Become Incidents