Skip to content

Instantly share code, notes, and snippets.

@hhenrichsen
Created February 3, 2022 05:11
Show Gist options
  • Save hhenrichsen/fef48f2a318e20da95da0c9adde1fb34 to your computer and use it in GitHub Desktop.
Save hhenrichsen/fef48f2a318e20da95da0c9adde1fb34 to your computer and use it in GitHub Desktop.
[alias]
co = checkout
s = status
c = commit
unstage = restore --staged --
pf = push --force-with-lease
new-branch = !git fetch -p && git stash push --include-untracked && git checkout master && git pull && git checkout -b \"$USER-$1\" && :
current-branch = branch --show-current
new-user-branch = !git fetch -p && git stash push --include-untracked && git checkout master && git pull && git checkout -b \"$USER-$1\" && :
# oldest-ancestor from https://stackoverflow.com/a/4991675
oldest-ancestor = !bash -c 'diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | head -1' -
rb = rebase --interactive --autosquash
auto-rebase = !git rb $(git oldest-ancestor)
changes-in = !git --no-pager show --stat --oneline --name-only $1 | tail -n +2 && :
changed-files = !git --no-pager show --stat --oneline --name-only $1 | tail -n +2 && :
fixup-existing = !git changed-files $1 | xargs -d \"\\n\" git add && git fx $1 && :
fixup = !git commit --fixup=$1 && :
fx = fixup
fxe = fixup-existing
nub = new-user-branch
nb = new-branch
[push]
default = current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment