-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitconfig
187 lines (166 loc) · 10 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# DETAILS: git global configuration to be used.
# CREATED: 07/01/06 15:24:33 IST
# MODIFIED: 13/10/24 01:57:43 PM +0530
# MODIFIED: 17/09/24 12:42:20 PM +0530
#
# AUTHOR: Ravikiran K.S., [email protected]
# LICENCE: Copyright (c) 2013, Ravikiran K.S.
#
# Debug Options
# export GIT_TRACE=2 GIT_TRACE_PACKET=2 GIT_TRACE_PACKFILE=2 GIT_CURL_VERBOSE=2
# export GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PERFORMANCE=2 GIT_TRACE_SETUP=2
# export GIT_SSH_COMMAND="ssh -vvv" GIT_TRACE_SHALLOW=2
# unset GIT_CURL_VERBOSE GIT_TRACE_PACK_ACCESS GIT_TRACE_SETUP GIT_TRACE_SHALLOW
# unset GIT_TRACE GIT_TRACE_PACKET GIT_TRACE_PACKFILE GIT_TRACE_PERFORMANCE
#
# Seeing diff between date ranges
# git log --after="2019-03-07" --before="2019-03-18" --oneline > hist-mar-07-18
# git log --after="2019-03-07" --before="2019-03-18" -p --no-prefix > hist-mar-07-18
#
# TODO: Incorporate below commands after checking their outputs and usefullness
# git show --pretty="" --name-only bd61ad98
# git diff-tree --no-commit-id --name-only -r bd61ad98
# git ls-tree --name-only -r <commit-ish>
# git diff-tree --no-commit-id --name-only -r <commit-ish>
# git show --stat --oneline HEAD
# git show --stat --oneline b24f5fb
# git show --stat --oneline HEAD^^..HEAD
# git show --name-only --oneline HEAD
# git show --name-only --oneline b24f5fb
# git show --name-only --oneline HEAD^^..HEAD
# git log --name-only
# git diff --name-only <sha>^ <sha>
# git diff --name-status <sha>^ <sha>
# git whatchanged <sha>
[diff]
color = auto
rename = copy
algorithm = patience
noprefix = true
# tool = mydiff
#[difftool "mydiff"]
# cmd = diff -Nwup $LOCAL $REMOTE
[gc]
auto = 1
[grep]
extendedRegexp = true
[merge]
summary = true
tool = vimdiff
conflictstyle = diff3
[mergetool]
prompt = false
[pager]
color = true
[status]
color = auto
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = auto
pager = true
[alias]
caa = commit -a --amend -c HEAD # amend last commit and put current staged changes into it
cia = commit -a # commit/checkin everything. Add -S option for signing
cln = !git gc && git remote -v prune origin # garbage collection internally calls prune to clean loose files. --dry-run
coa = !git checkout -- . # undo all changes in current directory
cmd = !git config -l | grep alias | cut -c 7- # show all git aliases. 'config --get-regexp alias' gives no-color output
cob = checkout -b # checkout to a new branch
dic = diff -p --no-prefix --cached # show staged changes from cache. --staged option is alias of --cached
dir = diff -p --no-prefix -r HEAD # show changes from last commit, both staged+unstaged. gnu-diff style --stat
dip = git format-patch HEAD~1
dih = diff -p --no-prefix -r # show changes from last commit, both staged+unstaged. gnu-diff style --stat
chk = apply -v -p0 --check --ignore-whitespace # check if patch file is fine. Assumes diff with --no-prefix option, gnu-diff style.
pat = apply -v -p0 --ignore-whitespace # apply the patch. Assumes diff generated with --no-prefix option
rev = !bash -c 'rd=rev_$RANDOM.diff && git dir >> $rd && git pat -R $rd && echo \"Reversed diff in $rd\" && unset rd' # reverse all changes
check = apply -v --check --ignore-whitespace # check if patch file is fine. Assumes diff with --no-prefix option, gnu-diff style.
clone = clone --recurse-submodules --remote-submodules -j8 # by default recurse sub-modules. --recursive option for git v1.9 or below
patch = apply -v --ignore-whitespace # apply the patch. Assumes diff generated with --no-prefix option
reverse = !bash -c 'rd=revu_$RANDOM.diff && git dih >> $rd && git pat -R $rd && echo \"Reversed unstaged diff in $rd\" && unset rd' # reverse unstaged changes
create = !bash -c 'git init && cp -f ~/conf/gitattributes .gitattributes && git add . && git commit -m \"First commit\"' # init git repo
amend = commit --amend # fix last commit. --no-edit if no need to edit commit log
diffstat= diff --stat -r HEAD # show summary of all changes from last commit
chnglog = log --pretty=format:\" * %s\" # Display commits summary
hist = log --date=short --pretty=format:\"%h %ad | %s %d [%an]\" --graph # history (date=local doesn't help)
lspriv = ls-files --other # --exclude-standard to not list files ignored in .gitignore. -z all output in single line.
rmpriv = clean -df # delete untracked private files in repo (-i ??)
taglist = tag -l # show commit messages on tag list
unadd = reset HEAD # un-add files from tracking index (still uncommitted new files)
pushto = "!f() { git push --all $@ && git push --tags $@; }; f" # pushes incremental changes to provided target
pullb = "!f() { git pull $@ && return || git mergetool; }; f" # automagically invokes vimdiff if conflicts seen
mergeb = "!f() { git merge $@ && return || git mergetool; }; f" # automagically invokes vimdiff if conflicts seen
rebaseb = "!f() { git rebase $@ && return || git mergetool; }; f" # automagically invokes vimdiff if conflicts seen
brclean = "!f() { git branch --merged ${1-master} | grep -v \"${1-master}$\" | xargs -r git branch -d; }; f" # delete merged local branches
remturl = "!f() { git remote set-url ${2-origin} $1; return $?; }; f" # change remote url for github repo from https to ssh
pulmerg = !bash -c '!f(){ git dir > git pull $@ && return || git mergetool; }; f' # copy a commit from another branch with source info. hash is unique across branches
save = !sh -c 'export PREV=$(git symbolic-ref HEAD|cut -d/ -f3-) && git checkout -b "$1" && git commit -am "$1" && git checkout "$PREV"' -
# 'git add -u' - add deleted files, but not new files. 'git add .' - add current & new files, but not deleted files.
aa = !sh -c 'git add --all . && git add -u' # 'git aa' - add all deleted, modified, and new files.
ai = add --interactive # superset of --patch. Can do not only chunk-by-chunk patch, but much more.
ap = add --patch # stage commits chunk by chunk interactively
br = branch -avv # all branches (local + remote/-r), verbose, recursive, along with commit msgs
bc = branch -a --contains # git bc <sha>. Gives the branch where given sha was committed
co = checkout # undo unstaged changes to a file <file> or to entire repo if input is '.'
cb = checkout -b # <branch> - checkout branch & make it current branch
cp = cherry-pick -x # copy a commit from another branch with source info. hash is unique across branches
gk = !gitk --all&
gx = !gitx --all
ig = status --ignored # ignored directory/files
lg = log -W -p HEAD # timeline
la = log -p --author="Ravikiran" # --after="2019-01-24" --before="2019-04-16"
li = ls-files -o # show all ignored files
ls = log --name-status -r --oneline # list of files changed. ex, cvs update. --date=short --pretty=format:\"%H | %ad\"
lu = log -u # show changes to a file.
lx = log --all --graph --decorate --simplify-by-decoration # graph
pa = !git pull --recurse-submodules --all # && git submodule update --init --recursive # --remote is not needed
rc = rebase --continue
rs = rebase --skip
ra = rebase --abort
rv = remote -v # show all remote urls
sa = "!f(){ test $# -ne 1 && echo "input stash number" || git stash apply "stash@{$1}"; return $?; }; f" # apply given git stash. Never use git stash pop
sd = "!f(){ test $# -ne 1 && echo "input stash number" || git stash drop "stash@{$1}"; return $?; }; f" # drop given git stash. Never use git stash clear
sl = stash list # list all git stashes
sh = show -M --no-prefix
si = !git submodule update --init --recursive # initialize all submodules in repo
sm = show -m # show merge diff
ss = "!f(){ test $# -eq 0 && echo "input stash comments" || git stash save $*; return $?; }; f" # save current changes into git stash and clean them
st = status -uall # repo status
su = status -uno # repo status
wc = log --stat --no-merges HEAD # list all commit filenames, stats; excluding merges. Enhanced whatchanged
dump = cat-file -p
type = cat-file -t
undo = reset --hard HEAD # DANGEROUS: Remove last commit, set up work tree exactly as it was before
uncommit = reset --soft HEAD^ # Remove last commit, but do not touch the working tree (files untouched)
uncommithard = reset --hard @{u} # Completely remove last commit, do not save anything.
# 1. switching back to the master branch from my generic "dev" branch
# 2. pulling from the remote
# 3. switching back to "dev"
# 4. rebasing "dev" against "master"
# 5. switching back to "master"
# 6. merging in the changes from "dev"
# 7. and finally running git wtf to show me what all my branches look like after the merge before I do a push.
publish = !git checkout master && git pull && git checkout dev && git rebase master && git checkout master && git merge dev && git wtf
[commit]
template = ~/conf/template/gitcommit
[branch]
autosetuprebase = always
[core]
excludesfile = /home/ravikiranks/.gitignore
editor = vim
pager = less -x1,5
[push]
default = current # simple
[pull]
rebase = true
[fetch]
prune = true
#[color "diff"]
#whitespace = tabwidth=4
[credential "https://github.com"]
helper =
helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper =
helper = !/usr/bin/gh auth git-credential