1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00
dotfiles/git/config
Joe Groocock cfbe6d6f0f
git: Allow git cleanmerged/defbranch to take args
These aliases now make zero assumptions about either branch or origin
names. They default to origin, and the primary branch is determined from
the refs/remotes/$remote/HEAD symbolic-ref, which will be pulled from
the remote if it's not known locally.
With these it is now possible to act on any remote/branch combination:

    # Get default branch for 'upstream' remote
    $ git defbranch upstream

    # Delete branches merged into the default branch of the 'upstream'
    # remote
    $ git cleanmerged upstream

    # Delete branches merged into the upstream/foo branch
    $ git cleanmerged upstream foo

Signed-off-by: Joe Groocock <me@frebib.net>
2022-10-24 14:51:42 +00:00

86 lines
1.9 KiB
Plaintext

[user]
name = Joe Groocock
email = me@frebib.net
signingkey = CFBB6A86
[core]
autocrlf = input
excludesfile = /home/frebib/.config/git/gitignore
pager = diff-highlight | $PAGER
[init]
defaultBranch = master
[interactive]
diffFilter = diff-highlight
[commit]
gpgsign = true
[fetch]
prune = true
[push]
default = upstream
[pull]
rebase = true
prune = true
[merge]
ff = only
[rebase]
autoStash = true
[remote "origin"]
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
[remote "upstream"]
fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*
[log]
date = iso8601-local
[format]
pretty = format:%h %Cblue%ad%Creset %ae %Cgreen%s%Creset
[alias]
verbs = !git log --pretty=format:'%s' | cut -d \" \" -f 1 | sort | uniq -c | sort -nr
pushall = !git remote | xargs -L1 git push
count = !echo $(pwd) && git rev-list HEAD --count
unpushed = !git log --oneline @{u}..HEAD
leaders = !git shortlog -s -n --all --no-merges
defbranch = "!defbranch() { \
r=\"${1:-origin}\"; \
{ \
git symbolic-ref \"refs/remotes/$r/HEAD\" || { \
git remote set-head \"$r\" -a >&2 && \
git symbolic-ref \"refs/remotes/$r/HEAD\"; \
}; \
} 2>/dev/null \
| sed \"s@^refs/remotes/$r/@@\"; \
}; defbranch"
cleanmerged = "!cleanmerged() { \
r=\"${1:-origin}\"; \
b=\"${2:-$(git defbranch \"$r\")}\"; \
git branch --merged \"$r/$b\" | \
grep -ve \"^\\\\*\" -e \"^. $b$\" | \
xargs -r git branch -d; \
}; cleanmerged"
[advice]
statusHints = false
pushUpdateRejected = false
detachedHead = false
[sendemail]
from = Joe Groocock <me@frebib.net>
smtpserver = smtp.zoho.com
smtpuser = me@frebib.net
smtpencryption = ssl
smtpserverport = 465
suppresscc = self
[diff]
algorithm = patience
[color]
ui = true
[color "diff"]
meta = cyan
frag = magenta
commit = yellow
old = red
new = green
whitespace = red 88 reverse
[color "diff-highlight"]
oldNormal = red
oldHighlight = red 88
newNormal = green
newHighlight = green 22
# vim: noet