/
.gitconfig
80 lines (79 loc) · 2.94 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
[core]
editor = code --wait
abbrev = 7
[user]
name = Matt Tingen
email = matt.tingen@gmail.com
[commit]
cleanup = strip
[push]
default = current
[merge]
conflictstyle = diff3
[rebase]
missingCommitsCheck = error
autoSquash = true
[rerere]
enabled = true
[diff]
tool = code
guitool = code
[difftool "code"]
cmd = code --wait --diff $LOCAL $REMOTE
[custom]
basebranch = main
[advice]
detachedHead = false
[init]
defaultBranch = main
[alias]
debug = !GIT_TRACE=1 git
s = status
ls = log --oneline
# Show child commits leading to the specified commitish
lsto = "! git ls --reverse --ancestry-path HEAD^..$1"
l = !sh -c 'git log --oneline \"$(git basebranch)\"..\"${1}\"' -
base = "!git co \"$(git basebranch)\""
co = checkout
c = commit
fix = commit --amend --no-edit
reword = commit --amend --only --no-verify
rw = reword
root = rev-parse --show-toplevel
d = difftool --gui --no-prompt
stashkeep = "!git stash -u && git stash apply"
# Rebase n most recent commits
rbn = "!sh -c \"git rebase -i @~$1\" -"
# Rebase from a specific commit forward
rbf = "!sh -c \"git rebase -i $1^\" -"
# Rebase commits since branching
rb = "!git rbn $(git l | wc -l | xargs)"
pushup = "!git push -u origin `git_branch`"
# Display recently committed branches
recent = !sh -c 'git for-each-ref --count=\"${1:-12}\" --exclude="refs/heads/bak-*" --sort=-committerdate refs/heads/ --format=\"%(refname:short)\"' -
logrecent = "!git log --branches --date='format:%R' --format='%Cgreen%ad%Creset %s' --author=\"$(git config user.name)\""
today = "logrecent --since=midnight"
yesterday = "logrecent --since="yesterday.midnight" --until=midnight"
msg = "log --format=%B -n 1"
wip = !sh -c 'git add . && git commit -nm \"WIP $1\"' -
# Undo a "WIP" commit, staging the changes
unwip = "reset --mixed HEAD~1"
# Undo a commit, copying the commit message and staging the changes
uncommit = "!git msg HEAD | pbcopy && git unwip"
hash = "rev-parse --verify HEAD"
baseconfig = "!git config --file $config_dir/.gitconfig"
# Claim existing changes on the branch as personal changes
claimbranch = "!git reauthor --old-email \"$(git config --get user.email)\" --correct-email \"$(git baseconfig --get user.email)\""
# Claim future changes in the repo as personal changes
claimrepo = "!git config --replace-all user.email \"$(git baseconfig --get user.email)\""
claim = "!git claimbranch && git claimrepo"
# Fuzzy find branch
fzb = !sh -c 'git recent 50 | fzf --preview \"git --no-pager l {}\"' -
# Fuzzy find commit
fzc = !sh -c 'git --no-pager l HEAD --format=\"%H %s\" | fzf --with-nth 2.. --preview \"git --no-pager show --color=always {1}\" | awk \"{print \\$1}\"' -
empty = commit --allow-empty
# The base branch for a repo is used by git aliases for e.g. abbreviated
# logging and quick interactive rebases.
setdefaultbasebranch = config --global --replace-all custom.basebranch
setbasebranch = config --replace-all custom.basebranch
basebranch = config --get custom.basebranch