Skip to content

Instantly share code, notes, and snippets.

@jonathanconway
Last active September 2, 2023 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanconway/6137884 to your computer and use it in GitHub Desktop.
Save jonathanconway/6137884 to your computer and use it in GitHub Desktop.
Useful Git aliases. Append this code to the .gitconfig file in your %USERPROFILE% folder.
[user]
name = Jonathan Conway
email = jonathan.conway@gmail.com
[alias]
bn = !git for-each-ref --format='%(refname:short)' `git symbolic-ref HEAD`
br = branch
c = commit
co = checkout
com = checkout master
cp = cherry-pick $0
cl = !sh -c 'git clone $0 $(echo $0 | cut -d. -f2 | cut -d/ -f2,3)'
df = diff
fe = fetch origin
ff = !sh -c 'BRANCH_NAME=$(git bn) && git merge --ff-only origin/$BRANCH_NAME'
hr = reset --hard
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
mt = mergetool
pf = push --force-with-lease
pmr = !git pr master
pr = !sh -c 'BRANCH_NAME=$(git bn) && git co $0 && git fe && git merge --ff-only origin/$0 && git co $BRANCH_NAME && git rb $0'
pushb = !sh -c 'BRANCH_NAME=$(git bn) && git push --set-upstream origin $BRANCH_NAME'
rb = rebase
rbc = rebase --continue
rbm = rebase master
st = status
stage = add -A
tagcommit = !sh -c 'git rev-parse --verify $0~0'
unstage = reset HEAD $1
who = shortlog -s --
[push]
default = current
[core]
excludesfile = /Users/jonathanconway/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[merge]
tool = opendiff
[commit]
template = /Users/jonathanconway/.stCommitMsg
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment