-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitconfig
156 lines (123 loc) · 6.79 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
143
144
145
146
147
148
149
150
151
152
153
154
155
[branch]
autosetuprebase = always
[alias]
# arc shortcuts
stack = rebase origin/master -i --exec 'arc diff HEAD^'
stack-amend = rebase origin/master -i --exec 'arc amend'
stack-show = !~/print-diffs-and-commits.py
# shortcuts for builtin git gui tool
gui = !sh -c /usr/local/opt/git/libexec/git-core/git-gui
g = gui
# clean visual summary of history tree
lg = log -n 30 --color --graph --branches --branches --remotes --tags --pretty=format:'%C(cyan)%h%C(reset) -%C(bold red)%d%C(reset) %s %C(green)(%C(reset)%C(bold green)%an%C(reset)%C(green): %cr)' --abbrev-commit --notes HEAD
# shortcuts for builtin history viewer gui tool
hist = !gitk --all --simplify-merges
h = !gitk --all --simplify-merges
histmp = !gitk --branches=[!/] --simplify-merges
# print commits since origin/master in nice format
preship = log origin/master.. --pretty=format:"%h%x09%an%x09%ad%x09%s"
# print summary of line change stats vs production branch
toship = diff --stat origin/production
# shortcut to print summary of line change stats
compare = diff --stat
# shortcut to print nicely formatted commits since a previous ref, like "git since HEAD~3" or "git since master"
since = !sh -c 'git log $1.. --pretty=format:"%h%x09%an%x09%ad%x09%s"' -
# shortcut to print most recent commit in a nice format
last = log HEAD~1.. --pretty=format:"%h%x09%an%x09%ad%x09%s"
# shortcut to remove and dump most recent commit into staging
uncommit = reset --soft HEAD~1
# basic checkout shortcuts
co = checkout
com = checkout master
cop = checkout production
cob = checkout -b
# basic stash shortcuts
st = stash
stp = stash pop
# basic branch shortcuts
br = branch
newb = checkout -b
delb = branch -D
# basic misc shortcuts
s = status
chp = cherry-pick
rv = revert
f = fetch
# push shortcuts
push-m = push origin master
push-p = push origin production
# push to current branch
push-b = !sh -c 'git push origin $(git branch-name)'
# force push to current branch
push-b-f = !sh -c 'git push origin $(git branch-name) -f'
# submodule shortcuts
smu = submodule update
sm = submodule
# rebase shortcuts
rb = rebase
rb-m = rebase origin/master
# rebase on remote branch with the same name as current branch
rb-b = !sh -c 'git rebase origin/$(git branch-name)' -
rb--c = rebase --continue
rb--a = rebase --abort
# safe hard reset shortcuts
reset-m = !sh -c 'git diff-index --quiet HEAD -- && git log HEAD^.. --pretty=format:\"Resetting from %h to origin/master\" && git reset --hard origin/master || echo "Reset aborted, remove or stash unstaged changes first!"'
reset-1 = !sh -c 'git diff-index --quiet HEAD -- && git log HEAD^.. --pretty=format:\"Resetting from %h to HEAD~1\" && git reset --hard HEAD^ || echo "Reset aborted, remove or stash unstaged changes first!"'
# Search for a string in commit content (committed code, not the message)
search = !sh -c 'git rev-list --all | xargs git grep' -
# Find up to 10 commits matching this text, show by branch. E.g. git find-b "My commit title"
find-c = !sh -c 'git log -n 10 --all --grep=\"$@\" --pretty=\"format:%H\"' -
find-b = !sh -c 'git find-c \"$1\" | xargs -n 1 -I@ sh -c \"git show -s --format=\\\"%C(cyan bold)%h%C(reset) %s\\\" @ && git branch --contains @\"' -
# pull up git history gui showing dangling commits, to help recover lost commits
recover = !gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )
# log my commits from the past week
standup = log --since=7.days --author=drew
# -----
# Shortcuts to list branches and stashes in order of most recently modified, and (for branches)
# a shortcut to check out by list number
# Branch List
# git brl lists the first 15 branches, while git brln takes a number input and lists that many branches
# > git brl
# 1) a-branch 16 hours ago f5c3a60a4 Drew
# 2) my-second-branch 5 days ago c6cb9b861 Drew
# ...
# 15) my-15th-branch 9 days ago 9ac6c1286 Drew
# > git brln 1
# 1) a-branch 16 hours ago f5c3a60a4 Drew
brl = !git for-each-ref --sort='-authordate' --format='%(align:50,left)%(refname)%(color:yellow bold) %(HEAD)%(end)%09%(color:reset)%(color:green)%(authordate:relative)%(color:cyan)%09%(objectname:short)%(color:reset)%09%(authorname)%(color:reset)' refs/heads | sed -e 's-refs/heads/--' | nl -w2 -d $'\n' -s') ' | head -n 15
brln = !sh -c 'git for-each-ref --sort=\"-authordate\" --format=\"%(align:50,left)%(refname)%(color:yellow bold) %(HEAD)%(end)%09%(color:reset)%(color:green)%(authordate:relative)%(color:cyan)%09%(objectname:short)%(color:reset)%09%(authorname)%(color:reset)\" refs/heads | sed -e \"s-refs/heads/--\" | nl -w2 -d $\"\\n\" -s\") \" | head -n $1' -
# Checkout from list
# git col <number> checks out the branch corresponding to that number in the list printed by "git brl"
# > git col 2
# Switched to branch 'my-second-branch'
col = !sh -c 'git checkout $(git branch-number $1)' -
# Stash List - prints out a nicely formatted summary of the last 10 items in the stash
stl = !git stash list -n 10 --stat --find-renames --pretty=format:'%<(11)%C(bold magenta)%gd%C(reset) %<(10)%C(cyan)%h%C(reset) %<(25)%C(yellow)%cr%C(reset)' | sed -E 's/stash@{([0-9]+)}/\\1:/g' | (echo '\n██████████ GIT STASH (first 10) ██████████\n' && cat && echo '\n██████████ END STASH CONTENTS ██████████')
# ------
# Helpers
# interal helpers for this file
branch-name = "!git rev-parse --abbrev-ref HEAD"
branch-number = "!git for-each-ref --sort='-authordate' --format='%(refname)' refs/heads | sed -e 's-refs/heads/--' | tail -n +$1 | head -n 1 #"
# Quote / unquote a sh command, converting it to / from a git alias string.
# - Makes writing aliases that parse correctly soo much easier.
# - Taken from https://stackoverflow.com/a/39616600/1212203
quote-string = "!read -r l; printf \\\"!; printf %s \"$l\" | sed 's/\\([\\\"]\\)/\\\\\\1/g'; printf \" #\\\"\\n\" #"
quote-string-undo = "!read -r l; printf %s \"$l\" | sed 's/\\\\\\([\\\"]\\)/\\1/g'; printf \"\\n\" #"
# Personal settings
[core]
editor = nano
pager = less -F -X
[user]
name = Drew
email = [email protected]
# workaround for freezeing on git push
[sendpack]
sideband = false
# Git LFS extension
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[sequence]
editor = /Users/drew/interactive-rebase-tool