-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
78 lines (60 loc) · 2.55 KB
/
.gitconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[user]
name = Logan Praneis
[alias]
s = status
co = checkout
# log the last commit
last = log -1 HEAD
# Open a diff in nvim diffview
dt = "! args=$@; shift $#; nvim -c \"DiffviewOpen $args\""
# Open PR in nvim diffview
pr = "!f(){ branch=${1:-$(git branch --show-current)}; target=${2:-origin/main}; nvim -c \"DiffviewOpen $target...$branch\"; };f"
# View what commits were merged as part of a merge commit
show-merge = "!f(){ merge_commit=${1:?Merge commit not provided}; git log --pretty=oneline $1^..$1 --abbrev-commit; };f"
# View what commits were merged as part of a merge commit, with graph and fancier merge-base
log-merge = "!f(){ merge=${1:?Merge commit not provided}; parents=$(git log $merge --pretty=format:%P -1); base=$(git merge-base --octopus $parents); shift 1; other_args=$@; git log --graph $base..$merge $other_args; };f"
# Simple git log
lg = log --graph --abbrev-commit --oneline
# Run git-absorb to automatically add fixup commits
absorb = "git-absorb"
# Safer push -f
pushf = "push --force-with-lease --force-if-includes"
# View recent branches with ahead, behind, committer, date, commit message
# git lastb <branch (default origin/main)> <num (default 10)>
lastb = "!r() { refbranch=$1 count=$2; git for-each-ref --sort=-committerdate refs/heads --format='%(refname:short)|%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)' --color=always --count=${count:-10} | while read line; do branch=$(echo \"$line\" | awk 'BEGIN { FS = \"|\" }; { print $1 }' | tr -d '*'); ahead=$(git rev-list --count \"${refbranch:-origin/main}..${branch}\"); behind=$(git rev-list --count \"${branch}..${refbranch:-origin/main}\"); colorline=$(echo \"$line\" | sed 's/^[^|]*|//'); echo \"$ahead|$behind|$colorline\" | awk -F'|' -vOFS='|' '{$5=substr($5,1,70)}1' ; done | ( echo \"ahead|behind|branch|lastcommit|message|author\n\" && cat) | column -ts'|';}; r"
[core]
# set delta as a default pager
pager = delta
# set nvim as a default editor
editor = nvim
[interactive]
diffFilter = delta --color-only
[delta]
# use n and N to move between diff sections
navigate = true
[merge]
conflictstyle = diff3
[diff]
algorithm = histogram
colorMoved = default
tool = difftastic
[difftool]
prompt = false
[difftool "difftastic"]
cmd = difft "$LOCAL" "$REMOTE"
[pager]
difftool = true
[log]
date = local
[rebase]
autosquash = true
[absorb]
maxStack=50
[init]
defaultBranch = main
[commit]
verbose = true
[rerere]
enabled = true
[push]
autoSetupRemote = true