-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple.sh
executable file
·117 lines (88 loc) · 2.01 KB
/
simple.sh
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
#!/bin/bash
set -e
##
# Functions
##
function pause {
read -p ""
}
function gitlg {
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %C(blue)(%an <%ae>)%Creset' --abbrev-commit --date=relative
}
function showlg {
echo && echo $1 && gitlg | more && echo
pause
}
function commitFile {
echo foobar > $1
git add $1
git commit -m "$1 added" --quiet
}
##
# Setup
##
mkdir git
cd git
git init >> /dev/null
##
# Initial commit
##
commitFile initial
##
# Feature-x
##
git checkout -b feature-x --quiet
for((i=1;i<=5;i++)); do commitFile $i; done
showlg 'feature-x log'
##
# Switch back to master
##
git checkout master --quiet
##
# Feature-y
##
git checkout -b feature-y --quiet
for((i=6;i<=10;i++)); do commitFile $i; done
showlg 'feature-y log'
##
# Create stage-n
##
git checkout master --quiet
git branch stage-n
##
# Create stage-n-feature-x and rebase onto stage-n
#
# Merge stage-n-feature-x onto stage-n
##
git checkout feature-x --quiet
git checkout -b stage-n-feature-x --quiet
git rebase stage-n --quiet
git checkout stage-n --quiet
git merge stage-n-feature-x --no-ff -m "Merge branch 'feature-x'" --quiet
showlg 'stage-n log (merged stage-n-feature-x)'
##
# Create stage-n-feature-y and rebase onto stage-n
#
# Merge stage-n-feature-y onto stage-n
##
git checkout feature-y --quiet
git checkout -b stage-n-feature-y --quiet
git rebase stage-n --quiet
git checkout stage-n --quiet
git merge stage-n-feature-y --no-ff -m "Merge branch 'feature-y'" --quiet
showlg 'stage-n log (merged stage-n-feature-y)'
##
# FF Merge stage-n onto master
##
git checkout master --quiet
git merge stage-n --ff-only --quiet
showlg 'master log (ff merged stage-n)'
##
# Cleanup - Don't need feature branches anymore if they are merged into master
##
git branch -D stage-n-feature-y >> /dev/null
git branch -D stage-n-feature-x >> /dev/null
git branch -D stage-n >> /dev/null
git branch -D feature-y >> /dev/null
git branch -D feature-x >> /dev/null
showlg 'master log (cleaned)'