If you’re using Oh My Zsh, you have access to a powerful set of git aliases that can significantly speed up your development workflow. The git plugin comes pre-installed and provides dozens of shortcuts for common git operations.
Essential Git Aliases# Here are the most useful git aliases that will transform your daily workflow:
Basic Operations# 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Status and information
gst # git status
gss # git status --short
gsb # git status --short --branch
gl # git pull
gp # git push
ga # git add
gaa # git add --all
gc # git commit --verbose
gcmsg # git commit --message
gca # git commit --verbose --all
gcam # git commit --all --message
# Branch operations
gb # git branch
gba # git branch --all
gbd # git branch --delete
gcb # git checkout -b
gco # git checkout
gcm # git checkout $(git_main_branch)
gcd # git checkout $(git_develop_branch)
copy
Advanced Workflow# 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
# Logging and history
glog # git log --oneline --decorate --graph
gloga # git log --oneline --decorate --graph --all
glol # git log --graph --pretty=format with colors
glola # git log --graph --pretty=format with colors --all
glo # git log --oneline --decorate
glg # git log --stat
glgp # git log --stat --patch
# Stashing
gsta # git stash push (or save on older git)
gstp # git stash pop
gsts # git stash show --patch
gstd # git stash drop
gstl # git stash list
gstaa # git stash apply
gstc # git stash clear
# Merging and rebasing
gm # git merge
gma # git merge --abort
gmc # git merge --continue
grb # git rebase
grba # git rebase --abort
grbc # git rebase --continue
grbi # git rebase --interactive
copy
Remote Operations# 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Remote management
gr # git remote
grv # git remote --verbose
gra # git remote add
grrm # git remote remove
grmv # git remote rename
grset # git remote set-url
# Fetching and pulling
gf # git fetch
gfa # git fetch --all --tags --prune
gfo # git fetch origin
gpr # git pull --rebase
gpra # git pull --rebase --autostash
gpu # git push upstream
gpv # git push --verbose
copy
Diff and Show# 1
2
3
4
5
6
7
# Diff operations
gd # git diff
gdca # git diff --cached
gds # git diff --staged
gdw # git diff --word-diff
gdt # git diff-tree --no-commit-id --name-only -r
gsh # git show
copy
My Most Used Aliases# Based on daily development work, here are the aliases I use most frequently:
gss
- Quick status checkgaa
- Add all changesgcmsg "message"
- Add all and commit with messagegp
- Push changesgco branch-name
- Switch branchesgcb new-branch
- Create and switch to new branchglog
- Beautiful git loggsta
- Stash changes quicklygstp
- Pop stashed changesgl
- Pull latest changesCommon Workflow Examples# Starting a new feature:# 1
2
3
gcm # Switch to main branch
gl # Pull latest changes
gcb feature-xyz # Create and switch to new branch
copy
Daily commit workflow:# 1
2
3
4
gss # Check status
gaa # Add all changes
gcmsg "Add new feature" # Commit with message
gp # Push to remote
copy
Reviewing changes:# 1
2
3
gd # Show unstaged changes
gdca # Show cached/staged changes
glog # Review commit history
copy
Working with stash:# 1
2
3
4
5
gsta # Stash current changes
gco other-branch # Switch to other branch
# ... do some work
gco original-branch # Switch back
gstp # Pop stashed changes
copy
Enabling the Git Plugin# If you don’t have the git plugin enabled, add it to your ~/.zshrc
:
Advanced Aliases# Reset and Restore Operations# 1
2
3
4
5
grh # git reset
grhh # git reset --hard
grhs # git reset --soft
grs # git restore
grst # git restore --staged
copy
Pro Tips# Use gss
for a short status format that’s easier to readCombine aliases : gaa && gcmsg "Quick fix" && gp
for rapid commitsUse gsta
and gstp
for quick context switchingglog
vs glol
- try both to see which format you preferLearn grbi
for interactive rebasing - it’s a game changerUse gpr
instead of gl
when you want to rebase instead of mergeCreating Custom Aliases# You can also create your own aliases in your ~/.zshrc
:
1
2
3
4
5
# Custom git aliases
alias gundo = 'git reset --soft HEAD~1'
alias gclean = 'git clean -fd'
alias gwip = 'git add -A && git commit -m "WIP"'
alias gfresh = 'git fetch --all && git reset --hard origin/$(git_current_branch)'
copy
Main vs Master Branch# Oh My Zsh intelligently detects whether your repository uses main
or master
as the default branch. The gcm
alias will switch to whichever is configured as your main branch.
Conclusion# Oh My Zsh git aliases can dramatically improve your development speed. Start with the basic ones (gst
, gaa
, gcam
, gp
) and gradually incorporate more advanced aliases into your workflow. Your future self will thank you for the time saved!
Remember: the key is consistency. Pick a set of aliases and use them regularly until they become muscle memory.