config/.gitconfig
2024-05-13 09:25:33 +02:00

179 lines
5.3 KiB
INI

# some tricks come from https://blog.gitbutler.com/git-tips-and-tricks/
[user]
name = Mathieu Maret
email = mathieu.maret@gmail.com
[color]
ui = auto
diff = auto
status = auto
branch = auto
[pack]
threads = 0
[alias]
st = status
ci = commit
cm = commit -m
cia = commit --amend
cias = commit --amend --no-edit
co = checkout
sw = switch
br = branch
df = diff
dc = diff --cached
# lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
lolp = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lg = log -p --pretty=fuller --abbrev-commit
lgg = log --pretty=fuller --abbrev-commit --stat
ls = ls-files
dt = difftool # to have diff with meld
mylog = log --committer=\"$(git config user.name)\"
please = push --force-with-lease
# Remove last commit but keep changes
undo = reset --soft HEAD^
revertpart = reset -p HEAD^
diffword = diff --color-words=.
save = stash save -u
#rebase last N commits
rb = "!f() { git rebase -i HEAD~$1; }; f"
#rebase since branching on branch N
rbi = !sh -c \"git rebase -i `git merge-base $1 HEAD`\" -
cleanbr = remote prune origin
cleanbrshow = remote prune origin --dry-run
cleanupbr = "!git branch --merged | grep -v '\\*\\|master\\|develop\\|dev' | xargs -n 1 git branch -d"
# Remove local branch that have been removed on the server
cleanupbrprune = "!git fetch --prune"
contains = !sh -c 'git branch -a --contains $1' -
wdiff = diff --word-diff=color --unified=1
first = rev-list --max-parents=0 HEAD # or use log --reverse
rebasestash = rebase --autostash # stash before rebase if needed
#Gitlab checkout merge request. e.g. get MR 5 on remote upstream git mr upstream 5
mr = !sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -
#Git reset upstream
ru = "!f() { \
REMOTES=$(git remote); \
REMOTE=\"origin\"; \
case \"$REMOTES\" in \
*upstream*) \
REMOTE=\"upstream\"; \
;; \
esac; \
git fetch $REMOTE; \
git update-ref refs/heads/master refs/remotes/$REMOTE/master; \
git checkout master >/dev/null 2>&1; \
git reset --hard $REMOTE/master >/dev/null 2>&1; \
git checkout - >/dev/null 2>&1; \
}; f"
code-changes = "!git log --format=format: --name-only | egrep -v '^$' | sort | uniq -c | sort -rg | head -10"
cc = "!git code-changes"
fixup = "commit --fixup"
ri = "rebase -i --autostash --autosquash"
up = pull --rebase --autostash
rebaseour = "rebase -Xours"
rank = "shortlog -s -n --no-merges"
root = rev-parse --show-toplevel
staash = stash --all
# -w ignore whitespace. -C 3 time, detect lines moved or copied in any commit
blamef = blame -w -C -C -C
# Show the log having the modificatoin for $1
search =!sh -c "git log -S $1 -p"
[rebase]
# when rebasing, update the other common branch too.
# See https://andrewlock.net/working-with-stacked-branches-in-git-is-easier-with-update-refs/
# Need git 2.38
updateRefs = true
[branch]
sort = -committerdate
#New branch track remote
#autosetupmerge = always
# Rebase on git pull
#autosetuprebase = always
# in .gitattributes
# *.doc diff=word
# *.xsl diff=excel
# *.xlsx diff=zip
# *.docx diff=wordx
# *.png diff=exif
[diff "odf"]
textconv=odt2txt
[diff "odt"]
textconv=odt2txt
[diff "pandoc"]
textconv=pandoc --to=markdown
prompt = false
[diff "wordx"]
textconv = docx2txt_wrap
[diff "word"]
textconv = catdoc
[diff "excel"]
textconv = strings
[diff "zip"]
textconv = unzip -c -a
[diff "exif"]
textconv = exiftool
[difftool "meld"]
path = /usr/bin/meld
trustExitCode = false
[difftool]
prompt = false
[diff]
tool = meld
compactionHeuristic = true
[mergetool "meld"]
path = /usr/bin/meld
trustExitCode = false
[mergetool]
# do not keep .ori file after a merge
keepBackup = false
[merge]
tool = meld
# tool = vimdiff
# conflictstyle = diff3
[push]
default = current #push to upstreal assuming same name for the upstream and current branch
#default = upstream # pushed to the configuer upstream branch
[credential]
helper = cache --timeout=3600
[sendemail]
from = Mathieu Maret <mathieu.maret@gmail.com>
smtpserver = smtp.gmail.com
smtpuser = mathieu.maret
smtpencryption = tls
smtpserverport = 587
# smtppass = PASS
[web]
browser = firefox
[rerere]
enabled = true
[pager]
log = /usr/share/git/diff-highlight/diff-highlight | less
show = /usr/share/git/diff-highlight/diff-highlight | less
diff = /usr/share/git/diff-highlight/diff-highlight | less
[interactive]
diffFilter = /usr/share/git/diff-highlight/diff-highlight
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
[pull]
#rebase = true
ff = only
[commit]
verbose = true
[column]
ui = auto
[gpg]
#Sign with ssh key (check signingkey)
format = ssh
[maintenance]
# start maintenance on a repo with git maintenance start
#repo = /home/mmaret/Sources/matos
[fetch]
#For large repo. Update the commit crash at each commit to have git log --graph super fast
#writeCommitGraph = true