Last active
February 22, 2023 16:16
-
-
Save brookinc/0c66264322fbe7894d844e29f7c2319e to your computer and use it in GitHub Desktop.
Git config settings that I like to reuse.
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] | |
add-branch = "!f(){ git fetch origin $1 && git branch $1 FETCH_HEAD && git checkout $1; }; f" | |
alias = "!f(){ git config --global alias.$1 \"$2\"; }; f" | |
aliases = config --get-regexp ^alias\\. | |
aliasverbose = "!sh -c '[ $# = 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1' -" | |
br = branch --contains | |
cherry-pick-external = "!f(){ git --git-dir=$1/.git format-patch -k -1 --stdout $2 | git am -3 -k; }; f" | |
cleanup = gc | |
cleanup-slow = gc --aggressive | |
curr-branch = symbolic-ref --short HEAD | |
find-file = "!git ls-files | grep -i" | |
find-string = grep -Ii | |
log-date = log --date=iso --pretty=format:"%C(yellow)%h\\ %ad\\ %Creset%s%Cgreen\\ [%cn]" -n 15 | |
log-files = log --numstat --pretty=format:"%C(yellow)%h\\ %Creset%s%Cgreen\\ [%cn]" -n 15 | |
log-graph = log --graph --color --branches --abbrev-commit --pretty=format:\"%Cred%h%Creset%C(yellow)%d%Creset%n%w(80)%s%n%Cgreen(%cr) %C(bold blue)<%an>%Creset%n\" -n 15 | |
log-hash = log --pretty=format:"%h" -n 15 | |
log-short = log --oneline -n 15 | |
# source: https://stackoverflow.com/a/52025740/5673556 | |
parent = "!git show-branch | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #" | |
pull-branch = "!f(){ git checkout $1 && git pull-sub; }; f" | |
pb = pull-branch | |
pull-main = pull-branch main | |
pull-sub = "!f(){ git pull && git sub; }; f" | |
pushf = push --force-with-lease | |
rbs = "!f(){ git fetch && git rebase -i $1 && git sub; }; f" | |
rebase-on-branch = "!f(){ git rbs origin/$1; }; f" | |
rb = rebase-on-branch | |
rebase-on-main = rebase-on-branch main | |
sh = show HEAD | |
sh1 = show HEAD~ | |
sh2 = show HEAD~2 | |
stashdiff = "!f(){ git stash show -p stash@{$1}; }; f" | |
sub = submodule update --init --recursive | |
sync = pull-sub | |
[core] | |
autocrlf = true | |
[fetch] | |
prune = true | |
[gc] | |
auto = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment