Last active
July 24, 2026 15:58
-
-
Save 0livare/4960a81addfbcdc48abfe855fae0af43 to your computer and use it in GitHub Desktop.
My git alias list. Running 'git alias' will pretty-print these commands to the terminal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Some options that may or may not be applicable to you | |
| [user] | |
| name = Zach Olivare | |
| email = zach@olivare.net | |
| [push] | |
| default = upstream # Push to the current branch's upstream branch by default | |
| [core] | |
| autocrlf = input # Force replacing CRLF line endings with LF | |
| ignorecase = false | |
| excludesfile = ~/.gitignore_global | |
| # editor = code --wait | |
| [merge] | |
| ff = no # Never fast forward merge (I would have just moved the branch pointer manually) | |
| tool = code # Use VS Code to merge | |
| [mergetool "code"] | |
| cmd = code --wait --merge $REMOTE $LOCAL $BASE $MERGED # Use VS Code as merge tool | |
| [credential] | |
| helper = osxkeychain | |
| helper = | |
| helper = /usr/local/share/gcm-core/git-credential-manager | |
| # helper = /usr/local/bin/git-credential-manager | |
| # A great syntax highlighter for diffs: https://github.com/dandavison/delta | |
| [pager] | |
| diff = delta | |
| log = delta | |
| reflog = delta | |
| show = delta | |
| # EVERYONE SHOULD SET THIS | |
| [pull] | |
| ff = only | |
| [init] | |
| # When running `git init` create main as the default branch instead of master | |
| defaultBranch = main | |
| [rerere] | |
| enabled = false | |
| # A long list of useful git aliases | |
| [alias] | |
| # === Common Commands === | |
| s = status # Shortcut for status | |
| b = branch # Shortcut for branch | |
| a = add . # Shortcut for "add ." | |
| f = fetch --all --prune # Fetch and prune all remotes | |
| po = push origin # Shortcut for push origin | |
| pu = push upstream # Shortcut for push upstream | |
| cp = cherry-pick # Shortcut for cherry-pick | |
| cpcont = cherry-pick --continue # Shortcut for cherry-pick --continue | |
| rh = reset --hard # Shortcut for reset hard | |
| r = rebase # Shortcut for rebase | |
| rcont = rebase --continue # Shortcut for rebase --continue | |
| rem = remote # Shortcut for remote | |
| pr = remote prune # Shortcut for remote prune | |
| prune = remote prune # Shortcut for remote prune | |
| pushf = push --force-with-lease # Force push, but only so long as nothing has been updated on the remote that I haven't fetched | |
| pushup = push up -u head # Create and track a remote branch with the same name as the current branch on remote 'up' | |
| # === Assorted === | |
| alias = "!grep -E '( =|^$)' ~/.gitconfig | sed -E -e 's/=.+#//' | less" # List formatted aliases and descriptions | |
| ignore = !git rm -r --cached . && git add . # Fix untracked files, commit all changes first | |
| hide = update-index --skip-worktree # Keep a certain file from appearing in diffs | |
| unhide = update-index --no-skip-worktree # Allow a hidden file to again appear in diffs | |
| # === File Management === | |
| un = reset HEAD # More logical name for reset HEAD | |
| disc = checkout -- # Reverts a path to the last committed state | |
| co = checkout # Shortcut for checkout | |
| sw = switch # Shortcut for switch | |
| # === Commit Commands === | |
| cm = commit -n # Shortcut for commit | |
| com = commit -nm # Commit with in-line message | |
| cam = commit -nam # Stage all tracked and untracked files and then commit with in-line message | |
| amend = commit -n --amend # Add staged files to the previous commit. Changes the SHA-1 of the previous commit | |
| fix = commit -n --amend --no-edit # Amend the previous commit with all currently staged changes, keeps the previous commit message | |
| afix = !git add . && git fix # Amend the previous commit with all changes, keeps the previous commit message | |
| fixup = !git add . && git fix && git push up --force-with-lease # Amend all current changes into the previous commit and force update the remote branch | |
| tmp = commit -nm 'WIP - incremental commit' # Quick command for saving work progress which will be modified later | |
| atmp = !git add . && git tmp # Make a temporary commit out of all current changes | |
| # === Working with Previous Commit Commands === | |
| r1 = reset HEAD^ # Move HEAD pointer back one commit and keep all changes in the working directory | |
| r2 = reset HEAD^^ # Move HEAD pointer back two commits and keep all changes in the working directory | |
| f1 = reset HEAD@{1} # Move HEAD pointer forward one commit | |
| # === Branch management === | |
| parseBranchName = !git branch | grep '*' | sed 's/* //' # Get the current branch name | |
| publish = !git parseBranchName | xargs git po -u # Create a copy of the current branch on origin | |
| pushup = !git branch | grep '*' | sed 's/* /head:zo\\//' | xargs git push up -u # Create current branch on remote 'up' with prefix 'zo/' | |
| del = branch -D # Delete local branch | |
| master = !git move master up/master | |
| main = !git move main up/main | |
| dev = !git move dev up/dev | |
| move = branch -f | |
| # === Logging === | |
| last = log -1 --decorate # Show the last commit on the current branch | |
| # Possible colors: normal, black, red, green, yellow, blue, magenta, cyan, white | |
| # Possible modifiers: bold (neon), dim, ul, blink, reverse | |
| # Common placeholders: %C()-change color, %h-short commit hash, %d-ref names, %cn-committer name, %ar-relative date | |
| pretty = log --pretty=format:"%C(auto)%h%d\\ %s\\ %C(cyan)[%aN]" # Colorize a oneline version of the log | |
| lsb = !git pretty --graph # List commits on this branch, formatted | |
| ls = !git pretty --graph --all # List all commits on all branches, formatted | |
| lsd = log --pretty=format:"%C(auto)%h%d\\ %s\\ %C(green)(%cr)\\ %C(cyan)<%aN>" --graph --all # List commits including date | |
| lsme = "!f() { me=\"$(git config user.name)\"; git pretty --graph $(git for-each-ref --format='%(refname) %(committername)' refs/heads/ | while read ref cn; do [ \"$cn\" = \"$me\" ] && echo \"$ref\"; done); }; f" # "ls me" - List all commits on branches authored by me | |
| local-branch-dates = !git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' # Get the activity date for each local branch | |
| remote-branch-dates = !git branch -r --sort=-committerdate --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)|%(color:magenta)%(authorname)%(color:reset)' --color=always | column -ts'|' | |
| copy = "!f() { git log --pretty=%B -1 \"${1:-HEAD}\" | pbcopy; }; f" # Copy the commit message of a commit to the clipboard (HEAD by default) | |
| search = !git pretty --all -S # Search for text within a commit | |
| [advice] | |
| mergeConflict = false | |
| [filter "lfs"] | |
| process = git-lfs filter-process | |
| required = true | |
| clean = git-lfs clean -- %f | |
| smudge = git-lfs smudge -- %f | |
| [diff "lockb"] | |
| textconv = bun | |
| binary = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment