Repository navigation
Expand file tree
/
Copy pathdot_gitconfig.tmpl
More file actions
115 lines (109 loc) · 4.85 KB
/
Copy pathdot_gitconfig.tmpl
File metadata and controls
115 lines (109 loc) · 4.85 KB
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
[user]
name = AJ Alon
email = {{ .email }}
[core]
editor = zed --wait
[init]
defaultBranch = main
[pull]
rebase = true
[push]
default = current
gpgSign = if-asked
autoSetupRemote = true
[stash]
showPatch = true
[rebase]
missingCommitsCheck = error
autoSquash = true
[branch]
autosetuprebase = always
[credential]
{{- if eq .chezmoi.os "darwin" }}
helper = osxkeychain
helper = cache --timeout=3600
{{- else }}
helper = manager
helper = cache --timeout=3600
{{- end }}
{{ if lookPath "gh" -}}
[credential "https://github.com"]
helper =
helper = !{{ lookPath "gh" }} auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !{{ lookPath "gh" }} auth git-credential
{{- end }}
[checkout]
defaultRemote = origin
[commit]
verbose = true
[diff]
colorMoved = default
[rerere]
enabled = true
[fetch]
prune = true
[alias]
# depends on external `wstatus` script/alias, not a built-in git command
st = wstatus
co = checkout
ci = commit
cp = cherry-pick
br = branch
# switch back to the previously checked out branch
nb = switch -
adp = add -p
cop = checkout -p -- .
rhp = reset HEAD -p
rsp = restore --staged -p
sp = stash -p
l = log -1 HEAD
l2 = log -2 HEAD
l3 = log -3 HEAD
# https://davidwalsh.name/get-default-branch-name
default-branch = !git remote show origin | grep 'HEAD branch' | cut -d' ' -f5
rebaseia = rebase -i --autosquash
# interactive autosquash rebase onto the repo's default branch
rebaseiam = !git rebase -i --autosquash $(git default-branch)
# safer force-push: aborts if the remote has commits you don't have locally
please = push --force-with-lease
praise = blame
# pull the default branch from upstream, then push it to origin — keep a fork in sync
syncfork = !git pull upstream $(git default-branch) && git push origin $(git default-branch)
# https://haacked.com/archive/2014/07/28/github-flow-aliases/
up = !git pull --rebase --prune \"$@\" && git submodule update --init --recursive
cob = checkout -b
# stage everything and commit in one step
cm = !git add -A && git commit -m
# quick checkpoint commit of all changes
save = !git add -A && git commit -m 'SAVEPOINT'
wip = commit -am "WIP"
# uncommit the last commit, keeping its changes in the working tree (unstaged)
undo = reset HEAD~1 --mixed
amend = commit -a --amend
# destructive: snapshot everything, then hard-reset it away (the commit stays dangling as a safety net)
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# checkout the default branch and delete local branches already merged into it
bclean = "!f() { git checkout \"${1-$(git default-branch)}\" && git branch --merged \"${1-$(git default-branch)}\" | grep -v \" ${1-$(git default-branch)}$\" | xargs git branch -d; }; f"
# pull the latest default branch, then run bclean — typical "finish a branch" cleanup
bdone = "!f() { git checkout \"${1-$(git default-branch)}\" && git up && git bclean \"${1-$(git default-branch)}\"; }; f"
# move the current branch's commits onto a new branch name and rebase onto a different base
migrate = "!f(){ CURRENT=\"$(git symbolic-ref --short HEAD)\"; git checkout -b \"$1\" && git branch --force \"$CURRENT\" \"${3-$CURRENT@{u}}\" && git rebase --onto \"${2-$(git default-branch)}\" \"$CURRENT\"; }; f"
# https://coderwall.com/p/euwpig/a-better-git-log
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# https://hackernoon.com/lesser-known-git-commands-151a1918a60
commend = commit --amend --no-edit
grog = log --graph --abbrev-commit --decorate --all --format=format:\"%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(dim white) - %an%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n %C(white)%s%C(reset)\"
# @jmbledsoe
# trim = delete all local branches except the current one and any checked out in another worktree
# (branches checked out in other worktrees are prefixed with '+' by `git branch`).
trim = "!f() { git branch | grep -v '^[*+]' | xargs git branch -D; }; f"
trimdryrun = "!f() { git branch | grep -v '^[*+]' | xargs cat; }; f"
# squash = similar to 'git merge --squash', but without committing
# soft-reset to the merge-base with the default branch, staging all commits since diverging (squash prep, no commit made)
squash = "!f() { git reset \"$(git merge-base \"${1-$(git default-branch)}\" \"$(git rev-parse --abbrev-ref HEAD)\")\"; }; f"
# list the 10 most recently updated local branches, sorted by commit date
branchdate = for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(authordate:short)%09%(objectname:short)%09%1B[0;33m%(refname:short)%1B[m%09"
# print the comment line(s) directly above `<name> = ...` in this config, e.g. `git aliashelp bclean`
aliashelp = "!f() { awk -v name=\"$1\" '/^\\t#/{c=c $0 \"\\n\"; next} $0 ~ (\"^\\t\"name\" =\"){printf \"%s\", c; exit} {c=\"\"}' ~/.gitconfig; }; f"