-
Notifications
You must be signed in to change notification settings - Fork 10
/
git-config
217 lines (158 loc) · 8.19 KB
/
git-config
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
######################
# CONFIGURATIONS TO CHANGE
######################
YOUR_NAME="name surname"
YOUR_EMAIL="[email protected]"
PATH_TO_KDIFF3="/Applications/kdiff3.app/Contents/MacOS/kdiff3"
######################
# This file contains useful git config commands with definitions
# All configs are set globally in order to make it available for all your projects
# Before running the commands, DO NOT FORGET to replace the words in curly braces with corresponding the data
######################
######################
# INITIAL SETUP
######################
# First config you have to do is to add your name and email to git
git config --global user.name "${YOUR_NAME}"
git config --global user.email "${YOUR_EMAIL}"
######################
# ALIASES
######################
# Shortcut for most used command as checkout
git config --global alias.co "checkout"
# Shortcut for most used command as status
git config --global alias.s "status -uall"
# Shows all branches including local and remote ones
git config --global alias.b "branch -av"
# Shows remote name - url mapping for fetch and push
git config --global alias.r "remote -v"
# Shows all existing tags
git config --global alias.t "tag -l"
# Combines git add all and git commit in one command
git config --global alias.ac '!git add -A && git commit'
# sychronize master branch without checking in it
git config --global alias.master 'fetch origin master:master'
# Shows diff between the version in working copy and the object database
git config --global alias.d "difftool"
# Shows diff between the version in working copy and staging area
git config --global alias.dc "difftool --cached"
# Shows diff between the version in working copy and staging area
git config --global alias.dl "difftool HEAD..HEAD~"
# FOR VERSIONS AFTER GIT v2.0
# Shows all existing tags in a sorted list
git config --global alias.t "tag -l --sort=version:refname"
# Displays commit graph is a nice colored view for all branches including stashes
# Use "-N" for displaying the last N commits
git config --global alias.las "log --graph --all --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
# Displays commit graph is a nice colored view for all branches
git config --global alias.la "log --branches --remotes --tags --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
# Displays commit graph is a nice colored view for just the current branch
# Use "-N" for displaying the last N commits
git config --global alias.lb "log --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
# Displays each commit with full details one after another in a list view
# Use "-N" for displaying the last N commits
git config --global alias.lf "log --format=fuller"
# Displays each commit as 1 line. It is mainly used to see commits in one shot.
# Use "-N" for displaying the last N commits
git config --global alias.l1 "log --stat --pretty=oneline"
# Displays reflog data with the information of related commits
git config --global alias.ref "log -g --pretty=format:'%C(yellow)%h%Creset %gD: %gs %Cred==>%Creset %C(yellow)%s%Creset (%cr) <%an>' --date=iso"
# Removes the change set of your last commit from the commit store (your project's object database)
# And keeps it in Index. The commit message of your last commit is also re-used in your next commit.
git config --global alias.amend "commit --amend -C HEAD"
# push new branch without setting a branch name to the upstream
git config --global alias.pnb "push -u origin HEAD"
# Displays the content of your given commit
# Usage: git showco COMMIT_ID
git config --global alias.showco "!git --no-pager show --stat --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# Removes all un-committed changes, including untracked files and the ones in Index
git config --global alias.clear "!git reset --hard HEAD; git clean -f"
# Removes all changesets from staging area
git config --global alias.unstage "reset HEAD"
# Shows commit messages one line per commit between 2 commits
# Use like "git changelog v01..HEAD"
git config --global alias.changelog "log --pretty=format:' * %s'"
# Displays last update date for all existing tags and branches in a graph view
# Then you can learn all old legacy branches and tags from old days
git config --global alias.dates "log --date-order --graph --tags --branches --simplify-by-decoration --pretty=format:'%ai %h %d'"
# Forces to run garbage collector to remove unreferenced objects and pack the others
git config --global alias.gc-all "-c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now gc --force"
######################
# CORE
######################
# Git does not mark your code if the line endings are changed
git config --global core.autocrlf "false"
# Sets the default editor for writing commit messages or editing interactive rebase commands to vim
git config --global core.editor "vim"
# Change the default pager application to 'less'
git config --global --replace-all core.pager "less -iXFR"
######################
# PUSH
######################
# FOR VERSIONS BEFORE GIT v2.0
# Before git v2, push command sends all your un-pushed commits regardless of checking the source branch
# It means you will push commits from other branches if you don't specify branch like "git push origin BRANCH_NAME"
# By changing the default behavior to simple, you guarantee to push the commits of your current branch only
git config --global push.default "simple"
######################
# BRANCH
######################
# Pull will always do fetch + rebase instead of fetch + merge as default behavior
git config --global branch.autosetuprebase "always"
# Whenever you create a branch via "branch" or "checkout -b" commands, git will automatically track the remote one
git config --global branch.autosetupmerge "always"
######################
# LOG
######################
# Print out the ref names of any commits that are shown. The ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ will be printed.
git config --global log.decorate "full"
# Shows timestamps in ISO 8601 format: http://en.wikipedia.org/wiki/ISO_8601
git config --global log.date "iso"
######################
# COLOR
######################
# Prints all outputs in color whenever possible
git config --global color.diff "auto"
git config --global color.status "auto"
git config --global color.branch "auto"
git config --global color.interactive "auto"
git config --global color.ui "auto"
######################
# DIFF
######################
# Changes the diff algorithm to a more efficient one
git config --global diff.algorithm "patience"
# Tell git diff to use mnemonic prefixes (index, work tree, commit, object) instead of the standard a and b notation
git config --global diff.mnemonicprefix "true"
# Allow git diff to do basic rename and copy detection
git config --global diff.renames "copies"
######################
# DIFFTOOL
######################
# Using kdiff3 for resolving for diffs.
git config --global difftool.kdiff3.path "${PATH_TO_KDIFF3}"
git config --global difftool.kdiff3.trustExitCode "true"
git config --global difftool.prompt "false"
git config --global diff.tool "kdiff3"
######################
# MERGE
######################
# Puts the commit messages of the ones that are merged to the commit message of the merge
git config --global merge.summary "true"
# Always show a diffstat at the end of a merge
git config --global merge.stat "true"
######################
# MERGETOOL
######################
# Using kdiff3 for resolving for resolving merge conflicts.
git config --global mergetool.kdiff3.path "{PATH_TO_KDIFF3}"
git config --global mergetool.kdiff3.trustExitCode "true"
git config --global mergetool.keepBackup "false"
git config --global merge.tool "kdiff3"
######################
# CREDENTIALS
######################
# if you're on Mac OS and used homebrew to install git, you can use the native Mac OS keystore
# Then there will be no need to enter your passphrase on every pull & push
git config --global credential.helper "osxkeychain"