Skip to content

Instantly share code, notes, and snippets.

@josephschmitt
Last active February 8, 2021 15:51
Show Gist options
  • Save josephschmitt/f8c4c73994634a7069701db4ba3ef246 to your computer and use it in GitHub Desktop.
Save josephschmitt/f8c4c73994634a7069701db4ba3ef246 to your computer and use it in GitHub Desktop.
Global .gitconfig file
[alias]
am = "!f() { git add .; git commit --amend; }; f"
bl = branch --list
bd = "!f() { git branch -D $1; }; f"
# Create a new branch based off origin/master or switch to a branch if it already exists
br = "!f() { cur_branch=$(git rev-parse --verify refs/heads/$1 2> /dev/null); if [[ -z $cur_branch ]]; then git checkout -b $1 ${2:-origin/master} --no-track; else git checkout $1; fi }; f"
# Switch to a new branch and delete the old branch
brd = "!f() { cur_branch=$(git rev-parse --abbrev-ref HEAD); git br $1 $2; git branch -d $cur_branch --force; }; f"
c = "!f() { if [[ ! -z "$1" ]]; then git commit -m \"$1\"; else git commit; fi; }; f"
ca = "!f() { git add .; git c \"$1\"; }; f"
cam = "!f() { git add .; git commit --amend --no-edit; }; f"
# Clean up and delete any branches with :gone remotes
cl = "!f() { remote=${1:-origin}; git fetch $remote; git remote prune $remote; git branch -vv | grep $remote'/.*: gone]' | awk '{print $1}' | xargs git branch -df; }; f"
co = checkout
d = diff HEAD .
lg = log --oneline --color --graph --decorate --all
lgg = log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
plr = "!f() { git fetch; git pull --rebase ${1:-origin} ${2:-master}; }; f"
rs = "!f() { git reset ${@:-HEAD~1}; }; f"
root = "!f() { if [ -n \"$(git rev-parse --show-cdup)\" ]; then echo $(git rev-parse --show-cdup); else echo .; fi; }; f"
st = status
sb = status -sbu
sh = show --pretty="format:" --name-only
# Shove changes to your origin. Less harsh than a forceful push
shv = push --force-with-lease
[branch]
autosetuprebase = always
[core]
editor = micro
[color]
ui = auto
[diff]
tool = micro
[difftool "default-difftool"]
cmd = micro --diff $LOCAL $REMOTE
[difftool "vscode"]
cmd = "code-insiders --wait --diff "
[difftool "micro"]
cmd = micro --diff $LOCAL $REMOTE
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
required = true
process = git-lfs filter-process
[merge]
tool = vscode
[mergetool]
keepBackup = true
[mergetool "vscode"]
cmd = "code-insiders --wait "
[pull]
rebase = true
[push]
default = current
[rebase]
autoStash = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment