Skip to content

Instantly share code, notes, and snippets.

@tcarrio
Created November 23, 2022 21:49
Show Gist options
  • Save tcarrio/9015027009a527f16d0e3f31579b4270 to your computer and use it in GitHub Desktop.
Save tcarrio/9015027009a527f16d0e3f31579b4270 to your computer and use it in GitHub Desktop.
Git config
[alias]
a = add
f = fetch
p = push
co = checkout
cm = commit
st = status
br = branch
rs = reset
rb = rebase
d = diff
ds = d --staged
# branch name
bn = br --show-current
# gets root directory
rd = rev-parse --show-toplevel
# gets latest shared commit
sr = merge-base HEAD
aa = "!git a $(git rd)"
fa = f --all
# shows commit history
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
# amend
am = "!git cm --amend --no-edit --date=\"$(date +'%Y %D')\""
# force with lease
pf = p origin HEAD --force-with-lease
# FORCEEEE
pff = p origin HEAD --force
# squash it
sq = "!gitsq() { git rb -i $(git sr $1) $2; }; gitsq"
# generate patch
gp = "!gitgenpatch() { target=$1; git format-patch $target --stdout | sed -n -e '/^diff --git/,$p' | head -n -3; }; gitgenpatch"
cob = co -b
rh = rs --hard
rho = "!git rh origin/$(git bn)"
[pull]
rebase = true
ff = only
[init]
defaultBranch = main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment