Skip to content

Instantly share code, notes, and snippets.

@dfmartin
Last active August 23, 2017 16:18
Show Gist options
  • Save dfmartin/06ee8bd22048a7e9a152e9ee675e2c1c to your computer and use it in GitHub Desktop.
Save dfmartin/06ee8bd22048a7e9a152e9ee675e2c1c to your computer and use it in GitHub Desktop.
git aliases
##
[alias]
co = checkout
cob = checkout -B
fp = fetch --prune
# log commands
lsg = log --all --graph --oneline --decorate
ls = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ll = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat --date=short
# delete unused branches
dub = "!f() { git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f"
# sync current branch with develop branch
devsync = !sh -c '_CURRENT_BRANCH=$(git symbolic-ref --short HEAD) && git checkout develop && git pull --ff && git checkout $_CURRENT_BRANCH && git merge develop' -
# http://haacked.com/archive/2014/07/28/github-flow-aliases/ (updated with egrep)
# delete all local branches that have already been merged to either dev or master. Does not remove remote branches.
bclean = "!f() { git branch --merged ${1-develop} | egrep -v 'develop|master' | xargs -r git branch -d; }; f"
# https://gist.github.com/robmiller/6018582#file-gitconfig-L40
# Mark a file as "assume unchanged", which means that Git will treat it
# as though there are no changes to it even if there are. Useful for
# temporary changes to tracked files
assume = update-index --assume-unchanged
# Reverse the above
unassume = update-index --no-assume-unchanged
# Show the files that are currently assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
[diff]
algorithm = patience
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment