命令行测试

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
[[email protected] ~]# mkdir testing
[[email protected] ~]# cd testing/
[[email protected] testing]
[[email protected] testing]# git init
Initialized empty Git repository in /root/testing/.git/
[[email protected] testing]# echo "123" > index.html
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "first commit"
[master (root-commit) b712131] first commit
 file changed, 1 insertion(+)
 create mode 100644 index.html
[[email protected] testing]# echo "a file" > a.txt
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "add a.txt"
[master 025e8a3] add a.txt
 file changed, 1 insertion(+)
 create mode 100644 a.txt
[[email protected] testing]# echo "b file" > b.txt
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "add b.txt"
[master f4b13b6] add b.txt
 file changed, 1 insertion(+)
 create mode 100644 b.txt
[[email protected] testing]# git log
commit f4b13b6d3fc390eacb59e0d6223ac37329d96d6f
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:36 2017 +0800
    add b.txt
commit 025e8a337bfe312065d93b040852ceb532ef6642
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:12 2017 +0800
    add a.txt
commit b712131d81e3224f72f97c76f855e28da413450e
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:21:35 2017 +0800
    first commit
[[email protected] testing]# git checkout -b dev
Switched to a new branch 'dev'
[[email protected] testing]# git status
On branch dev
nothing to commit, working directory clean
[[email protected] testing]# git log
commit f4b13b6d3fc390eacb59e0d6223ac37329d96d6f
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:36 2017 +0800
 
    add b.txt
 
commit 025e8a337bfe312065d93b040852ceb532ef6642
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:12 2017 +0800
 
    add a.txt
 
commit b712131d81e3224f72f97c76f855e28da413450e
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:21:35 2017 +0800
 
    first commit
[[email protected] testing]# echo "welcome to beijing" > test1.txt
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "test1"
[dev d224e8c] test1
 file changed, 1 insertion(+)
 create mode 100644 test1.txt
[[email protected] testing]# echo "welcome to shanghai" > test2.txt
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "test2"
[dev e254dd5] test2
 file changed, 1 insertion(+)
 create mode 100644 test2.txt
[[email protected] testing]# git log
commit e254dd5657d99ed287faf62f74b566a7ac1bf858
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:26:01 2017 +0800
 
    test2
 
commit d224e8cb4a51a65377c8d8eb75c3613b197e47a4
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:25:37 2017 +0800
 
    test1
 
commit f4b13b6d3fc390eacb59e0d6223ac37329d96d6f
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:36 2017 +0800
 
    add b.txt
 
commit 025e8a337bfe312065d93b040852ceb532ef6642
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:12 2017 +0800
 
    add a.txt
 
commit b712131d81e3224f72f97c76f855e28da413450e
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:21:35 2017 +0800
 
    first commit
[[email protected] testing]# git checkout master
Switched to branch 'master'
[[email protected] testing]# git status
On branch master
nothing to commit, working directory clean
[[email protected] testing]# echo "master1" > master1.txt
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "master1"
[master 1ebe653] master1
 file changed, 1 insertion(+)
 create mode 100644 master1.txt
[[email protected] testing]# echo "master2" > master2.txt
[[email protected] testing]# git add .
[[email protected] testing]# git commit -m "master2"
[master 814b217] master2
 file changed, 1 insertion(+)
 create mode 100644 master2.txt
[[email protected] testing]# git log
commit 814b217ae84ca4ad541c36d96e9b3c2744bca849
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:28:15 2017 +0800
 
    master2
 
commit 1ebe65348f73958eeafce158f922d83e386faa78
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:27:50 2017 +0800
 
    master1
 
commit f4b13b6d3fc390eacb59e0d6223ac37329d96d6f
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:36 2017 +0800
 
    add b.txt
 
commit 025e8a337bfe312065d93b040852ceb532ef6642
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:12 2017 +0800
 
    add a.txt
 
commit b712131d81e3224f72f97c76f855e28da413450e
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:21:35 2017 +0800
 
    first commit
[[email protected] testing]# git merge dev
Merge made by the 'recursive' strategy.
 test1.txt | 1 +
 test2.txt | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 test1.txt
 create mode 100644 test2.txt
[[email protected] testing]# git log
commit df1da42a6c93152001199d684f01702eb6cb622f
Merge: 814b217 e254dd5
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:29:35 2017 +0800
 
    Merge branch 'dev'
 
commit 814b217ae84ca4ad541c36d96e9b3c2744bca849
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:28:15 2017 +0800
 
    master2
 
commit 1ebe65348f73958eeafce158f922d83e386faa78
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:27:50 2017 +0800
 
    master1
 
commit e254dd5657d99ed287faf62f74b566a7ac1bf858
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:26:01 2017 +0800
 
    test2
 
commit d224e8cb4a51a65377c8d8eb75c3613b197e47a4
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:25:37 2017 +0800
 
    test1
 
commit f4b13b6d3fc390eacb59e0d6223ac37329d96d6f
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:36 2017 +0800
 
    add b.txt
 
commit 025e8a337bfe312065d93b040852ceb532ef6642
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:22:12 2017 +0800
 
    add a.txt
 
commit b712131d81e3224f72f97c76f855e28da413450e
Author: xiaoming <[email protected]>
Date:   Thu Dec 21 14:21:35 2017 +0800
 
    first commit

此时,整个分支合并图如下:

分支的状态会保留

自动化部署之git merge和git rebase的区别

如果使用git rebase dev,分支合并图如下:

分支的状态会清除

自动化部署之git merge和git rebase的区别