forked from paulirish/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitconfig
executable file
·130 lines (108 loc) · 3.8 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
[alias]
b = branch
c = commit -am
l = log --oneline
s = status
p = push
fp = push --force-with-lease
wt = worktree
amend = commit --amend --all --no-edit
sclone = clone --depth=1
undocommit = reset HEAD~
hreset = reset --hard
co = checkout
df = diff --color --color-words --abbrev
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit
cherrypick = cherry-pick
cp = cherry-pick
mergeorigin = !"git merge origin/$(git mainormaster)"
# Essentially GitHub's compare view: show all 'ahead' changes (incl working tree) vs the merge-base
diffbranch = !"git diff $(git diffbase)"
# Diff of branch that's not checked out. Doesn't include working tree (but obv doesnt need to)
diffbranch-that = !"git diff origin/$(git mainormaster)...\"$1\" #"
# Show commit log of unique commits of this branch (not on main)
diffcommitsfrommain = !"git log --no-merges origin/$(git mainormaster).."
# ^^ also, 2 vs 3 dots: so important. https://stackoverflow.com/a/48681527
# Squash a branch to one commit against a branch with many non-main commits.
# This can't be an alias, but here's the hack.
# # be on the new feature branch, be okay with rewriting it's history.
# git reset --soft (git merge-base Other_Branch_Name HEAD)
# Two utils:
# What's the ancestor commit this branch shares with main?
diffbase = !"git merge-base origin/$(git mainormaster) HEAD"
# Is it a `main` or a `master` repo?
mainormaster = !"git branch --format '%(refname:short)' --sort=-committerdate --list master main | head -n1"
# fyi to change a git checkout from master to main.. (gh's suggested commands:)
# git branch -m master main; git fetch origin; git branch -u origin/main main; git remote set-head origin -a
# commit (past) WIP changes with a message stating when they happened. (Cuz I sometimes leave changes uncommitted for a while, but want the dates for reference)
# todo: maybe use `git commit --date=X` to set a past date. would need to pick one, tho.
commitwip = !"git commit -am \"WIP changes from a while ago. Last modified on:\n$(( git diff --name-only --cached; git ls-files --modified ) | uniq | xargs gstat -c '- %.19y %N')\""
[core]
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
precomposeUnicode = true
# so much color
[color]
ui = auto
[color "diff"] # i still love these choices in 2022.
meta = yellow bold
commit = green bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
newMoved = cyan dim
oldMoved = blue dim
newMovedAlternative = cyan italic
oldMovedAlternative = blue italic
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "status"]
added = yellow
changed = green
untracked = cyan
[log]
# https://github.com/git/git/commit/acdd37769de8b0fe37a74bfc0475b63bdc55e9dc
date = human
# git mergetool
[merge]
tool = opendiff
renameLimit = 0
[url "[email protected]:"]
insteadOf = https://github.com/
[url "git://gist.github.com/"]
insteadOf = "gist:"
# correct typos
[help]
autocorrect = 1
# push easily. http://stackoverflow.com/a/23918418/89484
[push]
default = current
followTags = true
autoSetupRemote = true
[pull]
default = current
rebase = false
[checkout]
defaultRemote = origin
# use separate file for username / github token / etc
[include]
path = ~/.gitconfig.local
#[init]
# templatedir = ~/.git_template
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
required = true
process = git-lfs filter-process
[fetch]
prune = true
[stash]
showPatch = true
#
# faster git server communication.
# like a LOT faster. https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html
[protocol]
version = 2