-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript
executable file
·102 lines (88 loc) · 2.33 KB
/
script
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
#!/bin/bash
function restartHistory() {
#This function obliterates a branch
#$1 is the name of the branch to obliterate
echo "##restarting history"
git checkout $1
git checkout --orphan newbranch
git add -A
git commit -am "start over"
git branch -D $1
git branch -m $1
git push -f origin $1
rm *
git add -A
git commit -m "blank files"
git push -f origin $1
}
function remakeBranch () {
#This function resets a branch to master's current history
#$1 is the name of the branch to reset
echo "##remaking branch"
git checkout master
git checkout -b newbranch
git add -A
git commit -am "start from master"
git branch -D $1
git branch -m $1
git push -f origin $1
}
function writeFile() {
#This function writes some text to a file
#$1 is the file name
#$2 is the first line
#$3 is the second line
#$4 is the third line
rm $1
touch $1
echo $2 >> $1
echo $3 >> $1
echo $4 >> $1
}
function makeChangesInBranch() {
#This function makes changes to a file and then commits those changes to the correct branch
#$1 is the file name
#$2 is the first line
#$3 is the second line
#$4 is the third line
#$5 is the branch name
git checkout $5
writeFile $1 $2 $3 $4
git add -A
git commit -m "changes"
git push origin $5
}
#This is the start of the script
#delete the old local version and obliterate it
echo "##starting script"
rm -rf gittester
git clone https://github.com/djshapiro/gittester.git
cd gittester
restartHistory master
#pull remote versions of the two branches
git fetch origin v1
git checkout v1
git fetch origin v2
git checkout v2
#Make a file and put some stuff in it
git checkout master
echo "##making a new file"
writeFile file1 "stuff" "more-stuff" "[1,2,3]"
git add -A
git commit -m "added some stuff to file1"
git push -f origin master
remakeBranch v1
remakeBranch v2
#Put some changes in v1
makeChangesInBranch file1 "stuff-and-a-thing." "more-stuff" "[1,2,3,4]" v1
#Put some changes in v2
makeChangesInBranch file1 "stuff" "less-stuff" "[1,2]" v2
#merge them together. This represents the "bad" merge; we merge v2 into v1.
git checkout v1
git merge v2
makeChangesInBranch file1 "stuff" "less-stuff" "[1,2]" v1
#now make more changes in v1
makeChangesInBranch file1 "stuff" "less-stuff" "[1,2,3]" v1
#and let's try a correct merge (v1 into v2)
git checkout v2
git merge v1