-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmygitconf
executable file
·164 lines (164 loc) · 9.01 KB
/
mygitconf
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
#!/bin/bash
# vim: set filetype=sh tabstop=4 softtabstop=2 shiftwidth=2 expandtab cindent:
ifz-git-conf-global()
{
if [ -z "$(git config --global --get $1)" ] ; then
git config --global "$@"
fi
}
ifz-git-select-conf-global()
{
if [ -z "$(git config --global --get $1)" ] ; then
PS3="$1? "
select sel in $2; do
git config --global $1 $sel
break
done
fi
}
# git user
ifz-git-conf-global user.name 'YOUR NAME'
ifz-git-conf-global user.email '[email protected]'
# git core
ifz-git-conf-global core.editor "${GIT_EDITOR:-vim}" # $GIT_EDITOR > core.editor > $VISUAL > $EDITOR
git config --global core.quotepath false
git config --global core.whitespace cr-at-eol
# git commit template
ifz-git-conf-global commit.template ~/.commit_template
# git無視パターンファイルを作成して、登録する
# 1. core.excludesfile の初期値は $XDG_CONFIG_HOME/git/ignore なので、その場所に作る方法と、
# 2. 任意の場所にファイルを作成し、そのパスを core.excludesfile に設定する方法がある.
# 各プロジェクト固有な無視パターンについては proj/.gitignore または、proj/.git/info/exclude に作成する.
ifz-git-conf-global core.excludesfile ~/.gitignore_global
# git push
git config --global push.default simple
git config --global push.autoSetupRemote true
# git pull
git config --global pull.ff only
# git credential
if [ -d "/mnt/c/Program Files/Git/mingw64/" ]; then # WSL + "Git for Windows" on host WindowsOS.
ifz-git-conf-global credential.helper "/mnt/c/Program\\ Files/Git/mingw64/bin/git-credential-manager.exe"
fi
ifz-git-select-conf-global credential.helper "cache store git-credential-manager manager wincred"
# git rebase
git config --global rebase.autosquash true
# pager
pager="${PAGER:-less -FX}"
ifz-git-conf-global core.pager "$pager"
dir="/usr/share/doc/git/contrib/diff-highlight"
if [ -d $dir ] ; then
(cd $dir ; [ -e diff-highlight ] || sudo make ; sudo install diff-highlight /usr/local/bin)
fi
if [ -n "$(which diff-highlight)" ] ; then
ifz-git-conf-global pager.log "diff-highlight | $pager"
ifz-git-conf-global pager.diff "diff-highlight | $pager"
ifz-git-conf-global pager.show "diff-highlight | $pager"
fi
# tig
git config --global tig.tab-size 4
git config --global tig.mouse yes
# git log
git config --global log.date iso-local # YYYY-MM-DD hh:mm:ss +ZZZZ
# git diff
git config --global diff.indentHeuristic true
# git alias
git config --global alias.utf8 '!LANG=ja_JP.UTF-8 LESSCHARSET=utf-8 git'
git config --global alias.sjis '!LANG=ja_JP.SJIS LESSCHARSET=dos git'
git config --global alias.nkf '!f(){ cd ${GIT_PREFIX} ; git $@ | nkf -w; };f'
git config --global alias.st 'status'
git config --global alias.sts 'status --short --branch'
git config --global alias.sti 'status --ignored'
git config --global alias.stiv 'check-ignore -v'
git config --global alias.clone1 'clone --depth 1'
git config --global alias.sw 'switch'
git config --global alias.wk 'worktree'
git config --global alias.wka '!f(){ git worktree add wk.$1 $1; };f'
git config --global alias.ci 'commit'
git config --global alias.cia 'commit --amend'
git config --global alias.ciav 'commit -v --amend'
git config --global alias.cian 'commit --amend --no-edit'
git config --global alias.ciar 'commit --amend --reset-author'
git config --global alias.cira 'commit --reset-author'
git config --global alias.cif 'commit --fixup'
git config --global alias.cifa '!f(){ git commit --fixup=amend:$@; };f' # later git v2.32: update commit-message, and amend commit.
git config --global alias.cifr '!f(){ git commit --fixup=reword:$@; };f' # later git v2.32: only update commit-message.
git config --global alias.onstage 'add --patch'
git config --global alias.unstage 'reset --patch --'
git config --global alias.rollback 'reset --hard'
git config --global alias.recommit '!git reset HEAD^ && git commit -pvc ORIG_HEAD'
git config --global alias.rebasefix 'rebase --whitespace=fix'
git config --global alias.rebase-i '!git tag -f save && git rebase -i'
git config --global alias.cont '!args=$(git status | perl -ne "print \$1 if /git (\w+-?\w* --continue)/"); git ${args:-status}' # if you have extracted "git xxx --continue" from git-status-message then run it, else run "git status"
git config --global alias.abort '!args=$(git status | perl -ne "print \$1 if /git (\w+-?\w* --abort)/"); git ${args:-status}' # if you have extracted "git xxx --abort" from git-status-message then run it, else run "git status"
git config --global alias.tagsave 'tag -f save'
git config --global alias.pick 'cherry-pick -xe'
git config --global alias.cv 'cherry -v'
git config --global alias.fetcht 'fetch --tags -f'
git config --global alias.pullr 'pull --rebase'
git config --global alias.pullri 'pull --rebase=interactive'
git config --global alias.pullup 'pull --ff-only upstream master'
git config --global alias.pushf 'push --force-with-lease'
[ -n "$(git push -h | grep force-if-includes)" ] &&
git config --global alias.pushf 'push --force-with-lease --force-if-includes'
git config --global alias.pushu 'push --set-upstream'
git config --global alias.pushn 'push --dry-run --verbose'
git config --global alias.pushyn '!git log --stat @{upstream}..HEAD && git status -sb && read -p "push [y/N] " yn && [ "$yn" = y ] && git push'
git config --global alias.mergen 'merge --no-commit --no-ff --verbose'
git config --global alias.pulln 'pull --no-commit --no-ff --verbose'
git config --global alias.br 'branch'
git config --global alias.bl 'branch -avv'
git config --global alias.bh 'rev-parse --abbrev-ref HEAD' # later git1.8: 'symbolic-ref --short HEAD'
git config --global alias.bls 'branch -l --format="%(refname:short)"'
git config --global alias.top 'rev-parse --show-toplevel'
git config --global alias.tl 'tag -l -n'
git config --global alias.tld 'tag -l -n --format="%(refname:strip=2)%0a* %(authordate:iso) %(subject)"'
git config --global alias.rl 'remote -v'
git config --global alias.sl 'stash list'
git config --global alias.sld 'stash list --date=iso-local'
git config --global alias.slr 'stash list --date=relative'
git config --global alias.wl 'worktree list'
git config --global alias.al 'config --get-regexp alias.*'
git config --global alias.al-config '!git config --get-regexp "alias.*" | perl -lne "print if s/(alias\.\S+) (.+)/git config --global \$1 \x27\$2\x27/"'
show_option=''
[ -n "$(git config -H 2>&1 | grep show-origin)" ] && show_option='--show-origin'
[ -n "$(git config -H 2>&1 | grep show-scope)" ] && show_option='--show-origin --show-scope'
git config --global alias.cl "config $show_option --get-regexp"
git config --global alias.ul "config $show_option --get-regexp 'user.*'"
git config --global alias.crlf "config $show_option --get-regexp 'core.*crlf'"
git config --global alias.confg 'config --global'
git config --global alias.diffc 'diff --cached'
git config --global alias.difftoolc 'difftool --cached'
git config --global alias.diffs 'diff --stat'
git config --global alias.diffn 'diff --no-index'
git config --global alias.diffm 'diff --diff-filter=M'
git config --global alias.shows 'show --stat'
git config --global alias.showm 'show --diff-filter=M'
git config --global alias.sb 'show-branch'
git config --global alias.sba 'show-branch -a'
git config --global alias.today 'log --since midnight'
git config --global alias.todays 'log --since midnight --oneline --decorate'
git config --global alias.todayss 'log --since midnight --oneline --no-decorate'
git config --global alias.logs 'log --oneline --decorate'
git config --global alias.logsg 'log --oneline --decorate --graph'
git config --global alias.logss 'log --oneline --no-decorate'
git config --global alias.logsd 'log --format="%C(green)%ad(%ar) %C(red)%cd(%cr)%n%C(auto)%h%d %s%n"'
git config --global alias.logv 'log --decorate --graph --branches --stat --format=fuller'
git config --global alias.reflogv 'reflog --decorate --format=fuller'
git config --global alias.reflogd 'reflog --date=iso-local'
git config --global alias.reflogr 'reflog --date=relative'
git config --global alias.ignore '!vim -O $(git config --get core.excludesfile) $(git rev-parse --git-path info/exclude) $(git rev-parse --show-toplevel)/.gitignore'
git config --global alias.attributes '!vim -O $(git rev-parse --git-path info/attributes) $(git rev-parse --show-toplevel)/.gitattributes'
git config --global alias.ll 'ls-files'
git config --global alias.zip '!git archive --format zip -o `git rev-parse --abbrev-ref @`.zip HEAD'
git config --global alias.code "!GIT_EDITOR='code --wait' git"
git config --global alias.nano '!GIT_EDITOR=nano git'
git config --global alias.vim '!GIT_EDITOR=vim git'
git config --global alias.rdate '!git -c log.date=relative'
git config --global alias.hdate '!git -c log.date=human'
git config --global alias.nolog "!f(){ git \$@ -- ':!*.log'; };f"
git config --global alias.nohtm "!f(){ git \$@ -- ':!*.htm'; };f"
git config --global alias.foreach "!f(){ gcmd=\$1; shift; for file in \"\$@\"; do git \$gcmd -- \$file; done; };f"
echo '#### check user setting ####'
git ul
echo '#### check credential setting ####'
git cl credential.helper