DevFiddleDevFiddle
HomeToolsSnippetsArticles
Explore tools
Home>Snippets>Essential Git Aliases for Productivity
Git
#CLI#Productivity#Terminal

Essential Git Aliases for Productivity

A curated collection of time-saving Git aliases for git log tree graphs, undoing commits, and branch management.

October 10, 20262 min read

Git's command-line interface is immensely powerful, but typing verbose flags repeatedly reduces daily productivity. Adding these battle-tested aliases to your ~/.gitconfig streamlines your workflow.

The Aliases

Run the following terminal commands or paste them directly into your ~/.gitconfig file under the [alias] section:

[alias]
    # Clean visual commit graph tree
    lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
 
    # Quick short status
    s = status -s
 
    # Unstage files without changing contents
    unstage = restore --staged
 
    # Undo the last commit while keeping staged file changes
    undo = reset --soft HEAD~1
 
    # Discard all uncommitted changes and clean untracked files
    wipe = !git reset --hard HEAD && git clean -fd
 
    # View recently modified branches sorted by last commit date
    recent = branch --sort=-committerdate --format="%(committerdate:relative)%09%(refname:short)"
 
    # Pull changes including submodules with fast-forward only
    up = pull --ff-only --prune --recurse-submodules

How to Apply

To add an alias using the CLI directly:

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.s "status -s"
git config --global alias.undo "reset --soft HEAD~1"

Quick Verification

# View the tree graph:
git lg
 
# Inspect staged changes compactly:
git s

Related snippets

Explore more utility functions, patterns, and code snippets.

View all snippets
Python
Exponential Backoff Retry Decorator in Python

Automatically retry failed network calls or database operations with configurable exponential backoff.

#Python#Decorators#Networking
View snippet
TypeScript
Debounce Function with TypeScript

A type-safe debounce implementation that delays executing a function until a specified wait time has elapsed.

#TypeScript#Utilities#Performance
View snippet
JavaScript
Fetch with AbortSignal Timeout

Cancel hanging HTTP requests gracefully using AbortSignal.timeout and custom fallback controllers.

#JavaScript#Fetch#Async
View snippet
About© DevFiddle 2026