-
Notifications
You must be signed in to change notification settings - Fork 13
/
.gitconfig
142 lines (110 loc) · 7.11 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Author: Lucas Cimon (github.com/Lucas-C/dotfiles_and_notes)
# Note: .gitconfig format impose to double backslashes: \\
[alias]
br = branch
co = checkout
st = status
pff = push --force-if-includes --force-with-lease
# include creation dates into the output:
sl = stash list --date=local
wdiff = diff --word-diff
wshow = show --word-diff
mvbranch = branch -m
stashlist = stash list --date=local
unadd = reset HEAD
# USAGE: git g [-shortOps] $pattern [$files...]
g = "!bash -c 'opts=; while [[ $1 =~ -.+ ]]; do opts=\"$opts $1\"; shift; done; opts=\"$opts $1\"; shift; git grep --ignore-case --break --heading --color=always --line-number \"$opts\" $(git rev-list --all) \"$@\" | git subst-sha1' dumb_param"
# Utility sub-routine: replace long SHA-1 hashes by a short hash & the committer ISO 8601 date
subst-sha1 = "!bash -c 'while read line; do sha1=$(echo \"$line\" | grep -o \"[a-z0-9]\\{40\\}\"); if [ -z \"$sha1\" ]; then echo \"$line\"; else subst=$(git show --no-patch --format=format:\"%h %ci\" $sha1); echo \"$line\" | sed \"s/$sha1/$subst/\"; fi; done' dumb_param"
# Get the full history of the changes affecting a given line, using a regular expression
# !WARNING! git blame only returns the 1st REGEX match, if multiple matches exist the recursion may 'jump' to follow another line
# USAGE: git rblame -M -n -L '/REGEX/,+1' FILE
rblame = "!bash -c 'while line=$(git blame \"$@\" $commit 2>/dev/null); do commit=${line:0:8}^; [ 00000000^ = $commit ] && commit=$(git rev-parse HEAD); echo $line; done' dumb_param"
rblameshow = "!bash -c 'while line=$(git blame \"$@\" $commit 2>/dev/null); do commit=${line:0:8}^; [ 00000000^ = $commit ] && commit=$(git rev-parse HEAD); git show $commit; done' dumb_param"
# colored logs, one per line - Alt: -p to get full patch diff
dag = log --graph --format='format:%C(yellow)%h%C(reset) %C(blue)\"%an\" <%ae>%C(reset) %C(magenta)%cr%C(reset)%C(auto)%d%C(reset)%n%s' --date-order
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# Log using color, pager, and a graphical representation of branches/merges
l = log --pretty=format:'%Cred---------------------------------------------------------------%n%C(red)%h %C(yellow)%d %Cgreen(%ci) %C(red)<%ae>%Creset%n%s%n%n%b%n' --abbrev-commit --date=relative --graph --date-order --stat --color
# Better UI for common diff command: diff against upstream, use color & pager
diff2 =!git diff --patience --color origin/mainline | less -cR
# See diffstat(1) for info about what this looks like
diffstat = diff --stat -r
diffcached = diff --cached
# Generate a ReviewBoard-compatible diff
rb = diff --no-color -U999999
# Show the "upstream" remote branch which the local branch is tracking
origin =!git for-each-ref --format='%(upstream:short)' $(git symbolic-ref HEAD)
# When you can’t quite fit what you’ve done into a commit but daren’t stray too far from now without a backup'
snapshot = !git stash save "snapshot: $(date)" && git stash apply "stash@{0}"
startfeature = checkout -bi # Start a new feature on a new branch
refresh =!git fetch origin && git rebase origin/mainline # Occasionally update from remote mainline
finishfeature =!git fetch && git rebase origin/mainline && git checkout mainline && git merge –no-ff @{-1} # Update and Merge to local mainline
# To avoid commiting changes to tracked files
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assumed = "!git ls-files -v | grep ^h | cut -c 3-"
unstage = reset HEAD --
# USAGE: you can pass an optional file extension like .py or .c to only limit stats to files ending like this. FROM: http://stackoverflow.com/a/13687302
authors-stats = "!sh -c 'git ls-tree -r -z --name-only HEAD -- */*$1 | xargs -0 -n1 git blame --line-porcelain HEAD | grep \"^author \"|sort|uniq -c|sort -nr' dumb_param"
# List files by commit count to detect "hotspots" - Alt: garybernhardt/dotfiles/bin/git-churn
commits-heatmap = "!git ls-tree -r -z --name-only HEAD | xargs -0 -n1 -I{} sh -c 'echo $(git rev-list HEAD --count {}) {}' | sort -n"
ls-tags = "!git tag --list | xargs -I{} git show --no-patch --format=format:'{} %h %cd\n' {}^{commit} | sort --version-sort"
rm-tags = "!git tag --list | xargs -I{} git tag -d {}"
# List all [Labels] in commit msgs, stripping digits
ls-labels = "!git log --pretty=format:%s | sed -e 's/[0-9]//g' -e 's/^Revert \"//' -e 's/\\(\\[[^]]\\+\\]\\)[^[]*/\\1\\n/g' | grep -F [ | sort | uniq -c"
# List file changes (A/M/D) that affected a single directory
dir-history = log --name-status
branches = branch --all --format '%(align:left,40)%(if)%(push)%(then)%(color:green)%(else)%(color:red)%(end)%(refname:short)%(color:reset)%(end) %(objectname:short) %(authordate:short) %(align:left,20)%(authorname)%(end) %(contents:subject)'
prune-remotes-develop = "!git remote prune origin && git branch --merged develop | grep -v '^[ *]*develop$' | xargs --no-run-if-empty git branch -d"
prune-remotes-main = "!git remote prune origin && git branch --merged main | grep -v '^[ *]*main$' | xargs --no-run-if-empty git branch -d"
prune-remotes-master = "!git remote prune origin && git branch --merged master | grep -v '^[ *]*master$' | xargs --no-run-if-empty git branch -d"
prune-local-branches-without-remote = "!git branch -vv | grep -E ': (gone|disparue)\\]' | grep -v '\\*' | awk '{ print $1; }' | xargs -r git branch -D"
permission-reset = !git diff -p -R --no-color | grep -E \"^(diff|(old|new) mode)\" --color=never | git apply
# Source: How to properly rebase and deal with a contributor's PR gist -> https://gist.github.com/hkaj/97c16a9ec6df6e6f1e18
checkoutpr = "!f() { git fetch origin refs/pull/$1/head:pr/$1; git checkout pr/$1; }; f"
checkoutcontrib = "!f() { git fetch $1 $2 && git checkout -b $3 $1/$2 && git rebase main; }; f"
[apply]
whitespace = nowarn
[branch]
autosetuprebase = always # + git config branch.$branch.rebase true
[color]
ui = true
[core]
editor = vim
pager = less -FMRiX
trustctime = false
eol = lf
autocrlf = false
# To share the same CRLF settings: echo '*.txt -crlf' > .gitattributes
#[credential]
# can be emptied with: git credential-cache exit
#helper = cache --timeout=3600
# for $deity's sake, check that anything we're getting is complete and sane on a regular basis
[transfer]
fsckobjects = true
[fetch]
fsckobjects = true
[receive]
fsckObjects = true
[diff]
renames = true
submodule = log
[pull]
rebase = merges
[push]
default = simple # +>+>+ more secure than "matching", especially to avoid erasing remote changes on master when you push --force on a dev branch
followtags = true # Reason: http://stackoverflow.com/a/26438076/636849
[merge]
tool = vimdiff
[mergetool]
keeptemporaries = false
keepbackups = false
prompt = false
trustexitcode = false
[include]
path = ~/.gitconfig_user
[init]
defaultBranch = main
[gpg]
program = gpg2