Skip to content

Instantly share code, notes, and snippets.

@Camwyn
Last active September 10, 2024 18:24
Show Gist options
  • Save Camwyn/b2671739a82275d8375c to your computer and use it in GitHub Desktop.
Save Camwyn/b2671739a82275d8375c to your computer and use it in GitHub Desktop.
My aliases for git
[alias]
# list aliases
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /'
# list branches
br = branch
# show current branch - tried to use to get branch name for other aliases
bn = !git rev-parse --abbrev-ref HEAD
# git commit
cm = commit
# git add --all && git commit
cma = !sh -c 'git add --all && git commit -a' -
# git checkout
co = checkout
# create/checkout new branch
cob = checkout -b
# delete branch
del = !sh -c 'git branch -D $1' -
# git diff
df = diff
# show last commit details
last = cat-file commit HEAD
# colorful git log - should delete this, I don't really use it much
lg = log --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
mg = merge
# short log
slog = log --graph --all --topo-order --pretty='format:%h %ai %s%d (%an)'
# merge no fast-forward
mn = merge --no-ff
# pull and merge no fast-forward
mp = !sh -c 'git pull && git merge --no-ff $1' -
# add files to last commit - no message change
moar = !sh -c 'git add --all && git commit --amend --no-edit' -
# merge (no fast-forward) and then show status
ms = !sh -c 'git merge --no-ff && git st'
# show new commits
new = !sh -c 'git log $1@{1}..$1@{0} "$@"'
# set origin no push - for when working with a fork and you don't want to accidentally push to origin
nopush = git remote set-url --push origin no_push
# push a new branch
pub = !sh -c 'git push -u origin $( git rev-parse --abbrev-ref HEAD )'
# Pull and submodule update
ps = !sh -c 'git pull && git submodule update --init --recursive'
# git status
st = status
# update submodules recursively
sub = submodule update --init --recursive
# unstage all added files
unstage = reset HEAD
# remove file from git tracking
untrack = !sh -c 'git rm --cache $1' -
# show cached diff
dc = diff --cached
[core]
editor = code --wait
hooksPath = /Users/stephenpage/.git/hooks
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
[pull]
rebase = false
@Camwyn
Copy link
Author

Camwyn commented May 28, 2015

Note that ab, mm and svnp are the three parts of https://gist.github.com/Camwyn/c4496d9c064d67bd41f2
I don't work on VIP anymore, so I've removed these

@Camwyn
Copy link
Author

Camwyn commented May 19, 2016

I tried using variables for pub but they never worked correctly for me - thus this version of a publish shortcut.
Would be nice if you could use aliases in aliases...hmm...

@Camwyn
Copy link
Author

Camwyn commented Feb 14, 2017

Updated with descriptive comments
also added the tag push to git ab <branchname> ab removed as I no longer use it.

@Camwyn
Copy link
Author

Camwyn commented Sep 10, 2024

Removed some old aliases - haven't used them in a decade as I no longer work on WP VIP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment