-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitconfig
More file actions
132 lines (106 loc) · 3.76 KB
/
Copy pathgitconfig
File metadata and controls
132 lines (106 loc) · 3.76 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# many settings below came from https://github.com/jessfraz/dotfiles
[alias]
### git-branch
bname = branch --show-current
nb = switch -c
nu = !git branch -u origin/$(git bname)
### git-clone
# Clone a repository including all submodules
c = clone --recursive
### git-commit / git-add / git-push
amend = commit --amend --reuse-message=HEAD
amend-all = !"git add -u && git amend"
# Commit all changes
ca = !git add -A && git commit -av
ff = pull --ff-only
# create local branch on remote (set upstream)
sup = !git push -u origin $(git symbolic-ref --short HEAD)
unstage = reset --
### git-diff
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
staged = diff --cached
### git-log
l = log --pretty=oneline -n 20 --graph --abbrev-commit
lol = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
top = !git log --format=format:%an | sort | uniq -c | sort -r | head -n 20
### git-rebase
# Interactive rebase with the given number of latest commits
reb = "!r() { git rebase -i HEAD~$1; }; r"
### git-switch
# checkout an existing branch, an existing tag (detached HEAD), or create a new branch
# try and fix later maybe
# co = "!f() { msg=$(git switch "$1" 2>&1 >/dev/null); test $? -eq 0 && exit ; test \"${msg#*branch is expected, got tag}\" != \"$msg\" && git switch --detach $1 || git switch -c $1; }; f"
co = switch
# checkout a tag
tco = switch --detach
# rco = "!f() { [[ $# -eq 2 ]] || (echo must specify branch and remote name; exit 1); git branch | grep -qw "$1" && (git switch "$1" || exit $?) || git switch -c "$1" "$2/$1" ; }; f"
### search git
# Find commits by commit message or source
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
# find branches or tags containing a given commit
fb = "!f() { git branch -a --contains $1; }; f"
ft = "!f() { git describe --always --contains $1; }; f"
### housekeeping
# Remove branches that have already been merged with master a.k.a. ‘delete merged’
dm = "!git branch --merged | grep -v '\\*' | grep -vw 'dev\\|master\\|main' | xargs -n 1 git branch -d; git remote -v update -p"
### misc
remotes = remote -v
tags = tag -l
branches = branch -a
undo = !git reset HEAD~1 --mixed
alias = !git config -l | grep ^alias | cut -c 7- | sort
contributors = shortlog --summary --numbered
state = ! git describe --always --dirty | grep -o dirty || true
hash = ! git describe --dirty --abbrev=8 --always | sed -e 's/.*g//'
s = status -sb
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
# always use ssh
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
[credential]
helper = cache --timeout=3600
[help]
autoCorrect = -1
[push]
followTags = true
[merge]
log = true
[diff]
renames = copies
wsErrorHighlight = all
[fetch]
parallel = 0
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold # line info
old = red # deletions
new = green # additions
[color "status"]
added = yellow
changed = green
untracked = cyan
[pull]
rebase = false
[init]
defaultBranch = main
# store personal / user-specific settings in .inc
[include]
path = ~/.gitconfig.inc
[rerere]
enabled = true
[core]
excludesFile = ~/.gitignore