Git Alias
What is Git Alias?
Git Alias is a collection of git version control alias settings that can help you work faster and better. Git Alias provides short aliases such as s
for status, command aliases such as chart
and churn
, lookup aliases such as whois
and whatis
, workflow aliases such as topic-begin
for feature branch development, and more.
Setup
You can use Git Alias various ways:
-
Download the Git Alias file here: gitalias.txt.
-
Install Git Alias via a variety of ways: install guide.
-
Customize Git Alias aliases as you wish: customize guide.
Follow us
You can follow us on GitHub:
-
Git Alias account: https://github.com/gitalias
-
Git Alias repository: https://github.com/gitalias/gitalias
Short aliases
Short aliases are for frequent commands and options:
git add:
git branch:
- git b = branch
- git bm = branch --merged
- git bnm = branch --no-merged
- git bed = branch --edit-description
- git bsd = branch --show-description (polyfill)
git commit:
- git c = commit
- git ca = commit --amend
- git cam = commit --amend --message
- git cane = commit --amend --no-edit
- git ci = commit --interactive
- git cm = commit --message
git checkout:
git cherry-pick:
- git cp = cherry-pick
- git cpa = cherry-pick --abort
- git cpc = cherry-pick --continue
- git cpn = cherry-pick -n (--no-commit)
- git cpnx = cherry-pick -n -x (--no-commit and with a message)
git diff:
- git d = diff
- git dd = diff with our preferred settings
- git dc = diff --cached
- git ds = diff --staged
- git dwd = diff --word-diff
git fetch:
- git f = fetch
git grep:
git log:
- git l = log
- git ll = log list with our preferred short settings
- git lll = log list with our preferred long settings
- git lg = log --graph
- git lo = log --oneline
- git lor = log --oneline --reverse
- git lp = log --patch
- git lfp = log --first-parent
- git lto = log --topo-order
git ls-files:
- git ls = ls-files
- git lsd = ls-files --debug
- git lsfn = ls-files --full-name
- git lsio = ls-files --ignored --others --exclude-standard
git merge:
- git m = merge
- git ma = merge --abort
- git mc = merge --continue
- git mncnf = merge --no-commit --no-ff
git pull:
git rebase:
- git rb = rebase
- git rba = rebase --abort
- git rbc = rebase --continue
- git rbs = rebase --skip
- git rbi = rebase --interactive
- git rbiu = rebase --interactive @{upstream}
git reflog:
- git rl = reflog
git remote:
git revert:
git show-branch:
git submodule:
- git sm = submodule
- git smi = submodule init
- git sma = submodule add
- git sms = submodule sync
- git smu = submodule update
- git smui = submodule update --init
- git smuir = submodule update --init --recursive
git status:
git whatchanged:
- git w = whatchanged
Friendly aliases
Recommended helpers:
- git initer - Initialize a repo using our recommended way i.e. with an empty rebaseable commit
- git cloner - Clone a repo using our recommended way i.e. recursive include of submodules
- git pruner - Prune a repo using our recommended way i.e. prune everything unreachable now
- git repacker - Repack a repo our recommended way i.e. as Linus Torvalds describes
- git optimizer - Optimize a repo using our recommended way i.e. by pruning and repacking
Quick highlights:
- git chart - Show highlights chart of activity per author
- git churn - Show log of files that have many changes
- git summary - Show a summary of overview metrics
Branch names:
- git default-branch - Show the default branch name
- git current-branch - Show the current branch name
- git upstream-branch - Show the upstream branch name
- git topic-base-branch - Show the topic base branch name
Branch commits:
- git branch-commit-first - Show a branch's first commit hash (or hashes)
- git branch-commit-last - Show a branch's last commit hash (or hashes)
- git branch-commit-prev - Show a branch's previous commit hash (or hashes)
- git branch-commit-next - Show a branch's next commit hash (or hashes)
Friendly plurals:
- git aliases - List aliases
- git branches - List branches
- git tags - List tags
- git stashes - List stashes
Undo:
- git uncommit = reset --soft HEAD~1
- git unadd = reset HEAD
Logging & reporting:
Lookups:
- git whois - Try to figure out an author's information
- git whatis - Try to figure out an object's information
Commit details:
- git commit-parents - Show the commit's parents
- git commit-is-merge - Is the commit a merge commit?
- git commit-message-key-lines
Add all & edit all:
- git add-* - Add all files of a given type
- git edit-* - Edit all files of a given type
Alias helpers:
- git alias - Show help for git alias commands
- git add-alias - Create a new git alias
- git move-alias - Rename an existing git alias
Script helpers:
Remotes:
- git remotes-prune - For each remote branch, prune it
- git remotes-push - For each remote branch, push it
New repos:
- git init-empty - Initialize a repo with an empty rebaseable commit
- git clone-lean - Clone a repo as lean as possible
Hew branches:
- git hew - Delete all branches that are merged into a commit
- git hew-dry-run - Delete all branches that are merged into a commit (dry run)
- git hew-local - Delete local branches that are merged into a commit
- git hew-local-dry-run - Delete local branches that are merged (dry run)
- git hew-remote - Delete remote branches that are merged into a commit
- git hew-remote-dry-run - Delete remote branches that are merged into a commit (dry run)
Saving work:
- git archive - Create an archive file of everything in the repo
- git snapshot - Stash a snapshot of your current working tree
- git panic - When you're worried the world is coming to an end
Misc:
- git init-empty - Initialize a repo with an empty rebaseable commit
- git diff-*
- git grep-*
- git merge-span-* - Merge span aliases
- git orphans - Find all objects that aren't referenced by any other object
- git fixup - Fix a commit by amending it
- git rev-list-all-objects-by-size
- git rev-list-all-objects-by-size-and-name
- git cherry-pick-merge
- git refs-by-date - Sort by date for branches
Advanced aliases:
Workflow aliases
Topic branching for feature workflows:
- git topic-* - Read this first about topic aliases.
- git topic-base-branch - Show the topic base branch name
- git topic-begin - Start a new topic branch
- git topic-end - Finish the current topic branch
- git topic-sync - Synchronize the current topic branch
- git topic-move - Rename the current topic branch
Flow aliases:
- git get & git put
- git ours & git theirs
- git wip & git unwip
- git assume & git unassume
- git publish & git unpublish
reset & undo:
- git reset-* - Move backwards on the commit chain; synonym for undo-*
- git undo-* - Move backwards on the commit chain; synonym for reset-*
track & untrack:
- git track - Start tracking from a local branch to upstream branch
- git untrack - Stop tracking from a local branch to upstream branch
inbound & outbound:
- git inbound - Show incoming changes compared to upstream
- git outbound - Show outgoing changes compared to upstream
pull1 & push1:
Misc:
- git issues - Show issues that are described in commit messages
- git expunge - Use filter-branch to delete a file everywhere
- git reincarnate - Kill a branch then create it anew
- git diff-chunk - Do a diff of two chunks in revisions
- git last-tag - Show the last tag in the current branch
- git serve - Serve the local directory via git server daemon
- git track-all-remote-branches - Track all remote branches
- git cleaner - Clean a working tree using more power options
- git cleanest - Clean a working tree using the most power options
- git cleanout - Clean a working tree using typical options then checkout
Tooling aliases
Use gitk:
- git gitk-conflict - Use gitk to show conflicting merge
- git gitk-history-all - Use gitk to show full history
Use other version control systems:
Use graphviz:
- git graphviz - Use graphviz for display