Created
November 5, 2020 16:02
-
-
Save riceboyler/cc18adc44427c622b2deccbed9a8b5a3 to your computer and use it in GitHub Desktop.
Git Aliases (from Haack)
This file contains 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
# | |
# Include this in your own .gitconfig by using the | |
# [include] directive with the path to this file | |
# | |
# [include] | |
# path = ~/.gitconfig.aliases | |
# | |
# If you don't have any existing includes, you can add this via the following command | |
# | |
# git config --global include.path ~/.gitconfig.aliases | |
# | |
[alias] | |
abort = rebase --abort | |
aliases = "!git config -l | grep ^alias\\. | cut -c 7-" | |
amend = commit -a --amend | |
# Deletes all branches merged specified branch (or master if no branch is specified) | |
bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; }; f" | |
# Switches to specified branch (or master if no branch is specified), runs git up, then runs bclean. | |
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f" | |
# Lists all branches including remote branches | |
branches = branch -a | |
browse = !git open | |
# Lists the files with the most churn | |
churn = !git --no-pager log --name-only --oneline | grep -v ' ' | sort | uniq -c | sort -nr | head | |
cleanup = clean -xdf -e *.DotSettings* -e s3_keys.ps1 | |
# Stages every file then creates a commit with specified message | |
cm = !git add -A && git commit -m | |
co = checkout | |
cob = checkout -b | |
# Show list of files in a conflict state. | |
conflicts = !git diff --name-only --diff-filter=U | |
cp = cherry-pick | |
delete = branch -d | |
# Discard changes to a file | |
discard = checkout -- | |
ec = config --global -e | |
find = "!git ls-files | grep -i" | |
graph = log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset• %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order | |
grep = grep -Ii | |
hist = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all | |
history = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all | |
# Shows the commit message and files changed from the latest commit | |
latest = "!git ll -1" | |
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short | |
lost = fsck --lost-found | |
# A better git log. | |
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate | |
# Moves a set of commits from the current branch to another | |
migrate = "!f(){ CURRENT=$(git symbolic-ref --short HEAD); git checkout -b $1 && git branch --force $CURRENT ${3-$CURRENT@{u}} && git rebase --onto ${2-master} $CURRENT; }; f" | |
open = "!f(){ URL=$(git config remote.origin.url); open ${URL%.git}; }; f" | |
pr = "!f(){ URL=$(git config remote.origin.url); open ${URL%.git}/compare/$(git rev-parse --abbrev-ref HEAD); }; f" | |
publish = "!f() { git push origin $1 && git push drafts :$1 && git browse; }; f" | |
rba = rebase --abort | |
rbc = "!f(){ git add -A && git rebase --continue; }; f" | |
re = "!f(){ git fetch origin && git rebase origin/${1-master}; }; f" | |
remotes = remote -v | |
restore = "!f(){ git add -A && git commit -qm 'RESTORE SAVEPOINT'; git reset $1 --hard; }; f" | |
ri = "!f(){ git fetch origin && git rebase --interactive origin/${1-master}; }; f" | |
save = !git add -A && git commit -m 'SAVEPOINT' | |
set-origin = remote set-url origin | |
set-upstream = remote set-url upstream | |
st = status -s | |
stashes = stash list | |
sync = !git pull --rebase && git push | |
undo = reset HEAD~1 --mixed | |
# Unstage a file | |
unstage = reset -q HEAD -- | |
up = !git pull --rebase --prune $@ && git submodule update --init --recursive | |
wip = commit -am "WIP" | |
wipe = "!f() { rev=$(git rev-parse ${1-HEAD}); git add -A && git commit --allow-empty -qm 'WIPE SAVEPOINT' && git reset $rev --hard; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment