-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitrc.sh
More file actions
executable file
·129 lines (108 loc) · 3.19 KB
/
gitrc.sh
File metadata and controls
executable file
·129 lines (108 loc) · 3.19 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
#!/bin/bash
if [[ "$SHELL" =~ bash ]]
then
# Autocomplete for bash
source "${GITRC_PATH}/scripts/git-completion.bash"
source "${GITRC_PATH}/scripts/git-flow-completion.bash"
__git_complete g _git
__git_complete gti _git
__git_complete qg _git
__git_complete gf _git_flow
# Prompt
source "${GITRC_PATH}/git_ps1.sh"
fi
# git in English
alias git='LANGUAGE=en_US.UTF-8 git'
# Common misspell
alias gti='git'
alias gl='git l'
alias gll='git ll'
alias glg='git lg'
alias glgg='git lgg'
alias glll='git lll'
alias glllg='git lllg'
alias gst='git st'
alias gpush='git push'
alias gpull='git pull'
# git flow aliases
alias gf='git flow'
alias gff='git flow feature'
alias gffco='git flow feature checkout'
alias gffs='git flow feature start'
alias gfff='git flow feature finish'
alias gffph='git flow feature publish'
alias gffpl='git flow feature pull'
alias gfft='git flow feature track'
alias gfb='git flow bugfix'
alias gfbco='git flow bugfix checkout'
alias gfbs='git flow bugfix start'
alias gfbf='git flow bugfix finish'
alias gfbph='git flow bugfix publish'
alias gfbpl='git flow bugfix pull'
alias gfbt='git flow bugfix track'
alias gfr='git flow release'
alias gfrco='git flow release checkout'
alias gfrs='git flow release start'
alias gfrf='git flow release finish'
alias gfrph='git flow release publish'
alias gfrpl='git flow release pull'
alias gfrt='git flow release track'
alias gfh='git flow hotfix'
alias gfhco='git flow hotfix checkout'
alias gfhs='git flow hotfix start'
alias gfhf='git flow hotfix finish'
alias gfhph='git flow hotfix publish'
alias gfhpl='git flow hotfix pull'
alias gfht='git flow hotfix track'
export PATH=$PATH:${GITRC_PATH}/bin
# Checkout a branch with fallbacks on sub git repositories
cobr() {
default_branches="develop master"
branches_order=$*
if [ $# -eq 0 ]; then
echo "Need to provide at least 1 branch"
else
# Adding default branches at the end
branches_order="${branches_order} ${default_branches}"
for d in $(find . -name .git | sed 's@./@@; s@/.git@@')
do
# Apply command
pushd "$d" > /dev/null;
for b in ${branches_order}
do
if git checkout "$b" > /dev/null 2>&1
then
printf "%20s set to %s\n" "$d" "$b"
break;
fi
done
popd > /dev/null;
done
fi
}
# Find all commits (even in orphans) containing $1 in diff log.
function git_dig {
if [ $# -eq 0 ]; then
echo "Find all commits (even in orphans) containing $1 in diff log"
else
git rev-list --all | xargs git grep --threads 4 --color "$1"
#git log --pretty=format:'%Cred%h%Creset - %Cgreen(%ad)%Creset - %s %C(bold blue)<%an>%Creset' --abbrev-commit --date=short -G"$1" -- $2
fi
}
# Tag all git repositories under current path
# $1 is the tag name
# $2 is the tag comment
# $3 is the (optional) branch to use for tagging (master is default)
function tag_subgit {
tagName=$1
tagComment=${2}
branchToTag=${3:-master}
for d in $(find . -maxdepth 2 -name .git | sed 's@./@@; s@/.git@@')
do
pushd "$d" > /dev/null;
# -s to sign commit
LANG=en_US git tag -f -as "${tagName}" -m "${tagComment}" "${branchToTag}"
# then push tag
LANG=en_US git push -f origin "${tagName}"
done
}