Skip to content

Instantly share code, notes, and snippets.

@jcarsique
Created January 12, 2024 11:13
Show Gist options
  • Save jcarsique/ed3f544e97ca3a60e109cdedc81e2714 to your computer and use it in GitHub Desktop.
Save jcarsique/ed3f544e97ca3a60e109cdedc81e2714 to your computer and use it in GitHub Desktop.
Git config
[alias]
ls = "ls-tree --name-only"
ll = "ls-tree -l"
st = status -sb
ci = commit
co = checkout
br = branch
branches = branch -a
glog = log --graph --abbrev-commit --date=relative
mergenff = merge --no-ff
in = "!git remote update -p; git log ..@{u}"
out = log @{u}..
outall = log --branches --not --remotes=origin
#lg = log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an> %C(green bold)%G?' --abbrev-commit --color
lg = log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>' --abbrev-commit --color
logd = log --left-right --graph --cherry-pick --oneline ...@{u}
logone = log --pretty=format:'%C(auto)%m %h %Cgreen%ad %C(bold blue)%<(20)%aN %Creset%s %N %C(auto)%d %C(green bold)%G?' --left-right --cherry-pick --date=short
logshort = log --pretty=format:'%C(auto)%m %h %s %N %C(auto)%d' --left-right --cherry-pick --date=short
di = diff
dic = diff --staged
id = show -s --pretty=format:'%C(auto)%h%d'
idl = show -s --pretty=format:'%C(auto)%H%d'
pullr = "!git fetch \"$@\" && git rebase --autostash @{push}"
pullnor = pull --no-rebase
who = "shortlog -ne --format='%h %s'"
rollback = reset --soft HEAD^
lc = log --pretty=oneline --abbrev-commit --graph --decorate ORIG_HEAD.. --stat --no-merges
latest = for-each-ref --count=10 --sort=-committerdate --format='%(committerdate:short) %(refname:short)'
latestl = for-each-ref --count=10 --sort=-committerdate refs/heads --format='%(committerdate:short) %(refname:short)'
#authorship = "!git ls-files -z|xargs -0 -n1 -E'\n' | git blame --date short -wCMcp -- | perl -pe 's/^.*?\\((.*?) +\\d{4}-\\d{2}-\\d{2} +\\d+\\).*/\\1/'| sort | uniq -c | sort -rn"
authorship = "!git ls-files -z|xargs -0 -n1 git blame --line-porcelain HEAD|grep \"^author \"|sort|uniq -c|sort -nr"
fix = "!_() { : git rev-parse ; c=$(git rev-parse $1) && git commit --fixup $c && git -c core.editor=cat rebase -i --autosquash --keep-empty --autostash $c~; }; _"
rebasei = "!_() { : git rebase -i ; git diff-index --quiet HEAD; s=$?; [ $s != 0 ] && git stash; git rebase -i $1 && [ $s != 0 ] && git stash pop; }; _"
## git clone https://github.com/git-cola/git-cola ~/workspace/git-cola
xbase = "!GIT_SEQUENCE_EDITOR=$HOME/workspace/git-cola/share/git-cola/bin/git-xbase git rebase"
stash-rename = "!_() { : git stash drop ; rev=$(git rev-parse $1) && git stash drop $1 || exit 1 ; git stash store -m \"$2\" $rev;}; _"
rbranch-rename = "!_() { : git branch ; [ \"$#\" -lt 2 ] && echo 'Usage: rbranch-rename [remote] old_branch_name new_branch_name' && exit 1; \
if [ \"$#\" -gt 2 ]; then REMOTE=$1; shift; else REMOTE=origin; fi; git push $REMOTE $REMOTE/$1:refs/heads/$2 :$1; }; _"
oldest-ancestor = "!bash -c ': git branch ; diff -u1 <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | sed -ne \"s/^ //p\"' -"
pr-hash = "!sh -c ': git checkout ; git ls-remote origin| grep "refs/pull/$1/head"| cut -f1' -"
resign = "!_() { : git checkout ; [ \"$#\" -eq 0 ] && echo 'Usage: resign <rev-list>' && exit 2; \
git filter-branch --commit-filter ' \
if grep -q carsique <<<\"$GIT_COMMITTER_EMAIL\" ; then git commit-tree -S \"$@\"; else git commit-tree \"$@\"; fi' $1; }; _"
pr-list = "!hub pr list -f \"%sC%>(8)%i%Creset %<(20)%B %<(30)%H %t %>|(150)%au %l%n\""
contains = "!_() { p=$1; shift; for ref in $(git log --all --grep=$p --pretty='%h'); do git branch $* --contains $ref; git tag --contains $ref; done; }; _"
#pomversion = "!_() { git show $1:pom.xml|grep 'version>'|uniq -u; }; _"
pomversion = "!_() { : git show ; shas="${*:-'HEAD'}"; for sha in $shas; do (echo $sha; git show $sha:pom.xml|grep 'version>'|uniq -u); done; }; _"
ignore = "!_() { : git add ; echo "$@" >> $(git rev-parse --show-toplevel)/.gitignore; }; _"
[include]
path = ~/.config/git/aliases
#[includeIf "gitdir:~/workspace/"]
path = ~/.config/git/sonar/.gitconfig
[includeIf "gitdir:~/homespace/"]
path = ~/.config/git/personal/.gitconfig
[color]
diff = auto
interactive = auto
showbranch = true
sh = auto
branch = auto
grep = auto
ui = auto
status = auto
[core]
autocrlf = input
safecrlf = true
# git clone https://github.com/github/gitignore ~/workspace/gitignore
excludesfile = $HOME/workspace/gitignore/Global/Eclipse.gitignore
ignorecase = false
whitespace = trailing-space,space-before-tab
#pager = diff-so-fancy | less --tabs=4 -RFX
[init]
# mkdir -p ~/.git_template/hooks/
# wget https://gist.githubusercontent.com/jcarsique/7643059/raw/adc53560307a898c9327e4521c659072f90c7243/pre-commit -O ~/.git_template/hooks/pre-commit
templatedir = ~/.git_template
[apply]
whitespace = fix
[push]
default = upstream
autoSetupRemote = true
[branch]
autosetupmerge = true
autosetuprebase = always
[diff]
renames = true
copies = true
mnemonicprefix = true
tool = meld
wsErrorHighlight = all
[merge]
conflictstyle = diff3
tool = meld
renormalize=true
renameLimit = 10000
[mergetool]
keepBackup = false
[mergetool "diffmerge"]
cmd = diffmerge --merge --result=$MERGED $LOCAL $BASE $REMOTE
trustExitCode = true
[difftool "diffmerge"]
cmd = diffmerge $LOCAL $REMOTE
[difftool "kdiff3"]
trustExitCode = false
[mergetool "kdiff3"]
trustExitCode = false
[difftool "meld"]
trustExitCode = false
[mergetool "meld"]
trustExitCode = false
[guitool "Rebase onto..."]
cmd = git rebase
revprompt = yes
[guitool "Rebase/Continue"]
cmd = git rebase --continue
[guitool "Rebase/Skip"]
cmd = git rebase --skip
[guitool "Rebase/Abort"]
cmd = git rebase --abort
[guitool "Pull with Rebase"]
cmd = git pull --rebase
[gui]
spellingdictionary = none
encoding = utf-8
[achievement]
upload = true
# git clone https://github.com/jcarsique/git-achievements ~/workspace/git-achievements
dir = $HOME/workspace/git-achievements
[git-up "bundler"]
# sudo gem install git-up
check = true
[rerere]
enabled = true
[pull]
rebase = merges
[remote "origin"]
fetch = +refs/pull/*/head:refs/remotes/origin/pull/*
[gpg]
program = gpg2
format = ssh
[commit]
gpgSign = true
[tag]
forceSignAnnotated = true
[color "diff-highlight"]
oldNormal = red bold
oldHighlight = red bold 52
newNormal = green bold
newHighlight = green bold 22
[color "diff"]
meta = yellow
frag = magenta bold
commit = yellow bold
old = red bold
new = green bold
whitespace = red reverse
[diff "word"]
# Requires ~/bin/docx2txt executable containing: "docx2txt.pl $1 -"
# Used in Git attributes file with: "*.docx diff=word"
textconv = docx2txt
[diff "exif"]
# Used in Git attributes file with: "*.jpg diff=exif"
textconv = exiftool
[diff "zip"]
textconv = unzip -c -a
[diff "sopsdiffer"]
textconv = sops -d
#[url "ssh://[email protected]"]
# insteadOf = https://github.com
[credential]
helper = libsecret
[rebase]
autoStash = true
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
[advice]
skippedCherryPicks = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment