dotfiles/.gitconfig.inc/common.gitconfig

74 lines
2.0 KiB
Plaintext

[core]
eol = lf
[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
[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
# "back to the future": switch to default branch and pull
bttf = "!f() { DEFAULT=$(git default-branch); git switch ${1-$DEFAULT} && git pull --rebase --prune; }; f"
# Reset HEAD to last commit, but keep files as they are
uncommit = reset HEAD~1 --mixed
# 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"