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
[alias] | |
# https://stackoverflow.com/a/52913660/370695 | |
branch-local = "symbolic-ref --short HEAD" # https://stackoverflow.com/a/19585361/5353461 | |
branch-fetch = "!f(){ br=\"$(git branch-local \"$@\")\" && git config branch.\"$br\".remote || echo origin; };f" | |
branch-push = "!f(){ br=\"$(git branch-local \"$@\")\" && git config branch.\"$br\".pushRemote || git config remote.pushDefault || git branch-fetch; };f" | |
# shortcuts | |
st = status | |
sh = show | |
ci = commit | |
co = checkout | |
nb = checkout -b | |
br = branch | |
brr = branch -r | |
ls = ls-tree -r HEAD --name-only | |
sg = commit -m "¯\\\\_(ツ)_/¯" | |
ri = rebase -i | |
rri = rebase --root -i | |
fall = fetch --all --prune | |
amend = commit --amend --no-edit | |
pick = cherry-pick | |
shallow = clone --depth 1 | |
root = rev-parse --show-toplevel | |
# shell aliases always run from the top level of the repo | |
lt = "!f(){ git fetch --tags 2>/dev/null || true; git describe --tags \"$(git rev-list --tags --max-count=1)\"; };f" | |
plt = "!f(){ git checkout \"$(git lt)\"; };f" | |
reb = "!f(){ git pull --rebase \"$(git branch-local)\" \"$(git branch-fetch)\" \"$@\"; };f" | |
please = "!f(){ git push --force-with-lease -u \"$(git branch-push)\" HEAD \"$@\"; };f" | |
mvnb = "!f(){ git branch \"$1\" && git reset --hard \"$2\" && git checkout \"$1\"; };f" | |
# git add --patch, but it works with new files too | |
pa = "!f(){ cd \"${GIT_PREFIX-.}\"; git add -N \"$@\" && git add -p \"$@\"; };f" | |
cm = "!f(){ git commit -m \"$*\"; };f" | |
cp = "!f(){ git commit -m \"$*\" && git push; };f" | |
yolo = "!f(){ git commit -am \"¯\\\\_(ツ)_/¯\" && git push; };f" | |
# rename tag | |
retag = "!f(){ git tag --delete \"$1\"; git tag \"$1\"; };f" | |
# amend commit and force push to origin | |
derp = "!f(){ git commit --amend --no-edit && git please; };f" | |
# git change-commits GIT_COMMITTER_NAME "old name" "new name" | |
change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '$OLD' ]]; then export $VAR='$NEW'; fi\" $@; }; f " | |
# from https://help.github.com/articles/remove-sensitive-data | |
remove-file = "!f() { git filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $1\" --prune-empty --tag-name-filter cat -- --all; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment