dotfiles/.config/git/config.inc/common.gitconfig

91 lines
2.6 KiB
Text

[core]
# Normalize line endings
autocrlf = input
[advice]
detachedHead = false
[init]
defaultBranch = main
[pull]
ff = only
[push]
recurseSubmodules = check
[submodule]
recurse = true
[pager]
branch = false
config = false
stash = false
tag = false
[status]
submodulesummary = 1
[commit]
cleanup = scissors
[diff]
tool = vimdiff
guitool = gvimdiff
submodule = log
[diff "ansible-vault"]
textconv = ansible-vault view
[credential]
helper = /usr/lib/git-core/git-credential-libsecret
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
[pretty]
ls = tformat:%C(yellow)%h %Cgreen%ad %Creset%s %Cblue[%an]%C(auto)%d
lsd = tformat:%>|(13)%C(yellow)%h %Cgreen%ad %Creset%s %Cblue[%an]%C(auto)%d
[alias]
# Various aliases for showing pretty and compact git logs
ls = log --pretty=ls --decorate --date=iso
lsd = log --pretty=lsd --decorate --date=iso --all --graph
# Compact version of git status
stat = status -s
# Get name of remote default branch (e.g. main or master)
default-branch = !git symbolic-ref --short refs/remotes/origin/HEAD | sed 's!^origin/!!'
# Push a new branch to origin by setting the upstream branch
push-new = "!f() { CURRENT=$(git branch --show-current); git push -u origin ${1-$CURRENT}; }; f"
# Push with ci.skip option (probably only works with GitLab)
push-skip-ci = push -o ci.skip
# Push with --force-with-lease, like force push but less risky. Should be used after a rebase.
push-softly = push --force-with-lease
# "back to the future": switch to default branch and pull
# TODO: Add `git stash push/pop`, but only if there actually is something to stash... not quite sure how
bttf = "!f() { DEFAULT=$(git default-branch); git switch ${1-$DEFAULT} && git pull --rebase --prune; }; f"
stash-bttf = !git stash && git bttf && git stash pop
# Reset HEAD to last commit, but keep files as they are
uncommit = reset HEAD~1 --mixed
# Shortcut for rebase --continue
rebase-c = rebase --continue
# Stash changes, pull and pop stash again
stash-pull = !git stash && git pull && git stash pop
# Submodule helpers
sm-update = submodule update --init --recursive --remote --merge
# Checkout a branch from a pull request (supported by GitHub)
checkout-pr = "!f() { [ $# -ge 1 ] || { echo 'Usage: git fetch-pr PULL_REQUEST_ID [BRANCH_NAME]'; exit 1; }; BRANCH=${2-pull-request-$1}; git fetch origin pull/$1/head:$BRANCH && git switch $BRANCH; }; f"