DevOps
Terminal Git Productivity
Supercharge your terminal Git workflow with aliases, shell completion, lazygit, tig, delta diff viewer, git-prompt customization, and git-branchless.
- Developers using Git in CI/CD pipelines and IDE integrations
- Readers who want to understand Git operation boundaries in automation
- Basic understanding of branch, commit, and push
- Basic CI/CD concepts
- Misusing GITHUB_TOKEN causing security issues
- Not understanding the trade-off between shallow and partial clone
- Relying on IDE operations without understanding underlying Git behavior
What you will learn
- Understand the core purpose of Terminal Git Productivity
- Master the basic usage and common options of Terminal Git Productivity
- Supercharge your terminal Git workflow with aliases, shell completion, lazygit, tig, delta diff viewer, git-prompt customization, and git-branchless.
- Understand key concepts: Git Aliases
- Know when to use this feature and when to avoid it
Start with a problem
Your team is adopting CI/CD pipelines, or you're configuring Git integration in your IDE — but you're unsure how Git behaves differently in automated environments compared to local manual operations.
One-Sentence Understanding
The terminal is Git's native habitat — with aliases, dedicated tools, and a customized prompt, you can accomplish in one keystroke what takes five commands in a GUI.
Git Aliases
[alias]
st = status
co = checkout
br = branch
ci = commit
di = diff
lg = log --oneline --graph --all --decorate
aa = add --all
unstage = reset HEAD --
undo = reset --soft HEAD~1
ri = rebase -i
tree = log --all --graph --oneline --decorate
cleanup = !git branch --merged main | grep -v \" main\" | xargs -r git branch -d
lines = !git log --author=\"$(git config user.name)\" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added: %s, removed: %s, total: %s\", add, subs, loc }'
Shell Completion
Bash:
source /usr/share/bash-completion/completions/git
export GIT_PS1_SHOWDIRTYSTATE=true
Zsh (oh-my-zsh):
plugins=(git gitfast)
Fish (built-in):
abbr -a gst 'git status'
abbr -a gco 'git checkout'
abbr -a glg 'git log --oneline --graph --all --decorate'
lazygit
brew install lazygit
cd my-project && lazygit
| Panel | Key | Action |
|---|---|---|
| Files | Space | Stage/unstage |
| Files | c | Commit |
| Branches | b | Switch branch |
| Commits | s | Squash |
Set delta as pager: git.paging.pager: delta.
tig
brew install tig
tig # Commit history
tig status # Status view
tig blame file # Blame
delta — Enhanced Diff
[core]
pager = delta
[delta]
side-by-side = true
line-numbers = true
syntax-theme = Dracula
Features: syntax highlighting, side-by-side view, line numbers, navigation.
git-prompt
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUPSTREAM="auto"
PS1='\w$(__git_ps1 " (%s)")\$ '
Or use starship:
[git_branch]
format = "on [$symbol$branch]($style) "
[git_status]
staged = "+\${count}"
modified = "!\${count}"
git-branchless
brew install git-branchless
git sl # Smart commit graph
git undo # Undo last operation
git restack # Fix broken dependencies
git record # Interactive stage & commit
Other Tools
| Tool | Purpose |
|---|---|
| git-extras | Extra Git commands |
| gh (GitHub CLI) | GitHub from CLI |
| forgit | fzf Git integration |
| gita | Multi-repo management |
Try it yourself
- Practice the terminal-git-productivity command in a test repository and observe state changes before and after
- Experiment with different options and compare the output differences
- Simulate a real scenario where you would need to use this, and walk through the full process
Continue Learning
commands/git-config— Git configuration referencecommands/git-log— Advanced git log usagebest-practices/git-aliases— Git alias best practices
Previous / Next
PreviousIntelliJ IDEA Git Deep DiveCommands
NextNo more reads in this direction