回答編集履歴

3

m

2019/11/28 12:25

投稿

yumetodo
yumetodo

スコア5850

test CHANGED
@@ -284,32 +284,36 @@
284
284
 
285
285
  * 41e0281 init commit
286
286
 
287
+ ```
288
+
289
+
290
+
291
+ このようにtreeが分岐していることがわかると思います。余談ですが
292
+
293
+
294
+
295
+ ```
296
+
297
+ alias glo='git log --oneline'
298
+
299
+ alias glog='git log --oneline --graph'
300
+
301
+ alias gloga='git log --oneline --graph --all'
302
+
303
+ alias glogar='git log --oneline --graph --all --remotes'
304
+
305
+ ```
306
+
307
+
308
+
309
+ のようなaliasを貼っておくと便利です(上記はbashのaliasの記法)
310
+
311
+
312
+
287
313
  ---
288
314
 
289
315
 
290
316
 
291
- このようにtreeが分岐していることがわかると思います。余談ですが
292
-
293
-
294
-
295
- ```
296
-
297
- alias glo='git log --oneline'
298
-
299
- alias glog='git log --oneline --graph'
300
-
301
- alias gloga='git log --oneline --graph --all'
302
-
303
- alias glogar='git log --oneline --graph --all --remotes'
304
-
305
- ```
306
-
307
-
308
-
309
- のようなaliasを貼っておくと便利です(上記はbashのaliasの記法)
310
-
311
-
312
-
313
317
  > また、新しくPull Requestを作り直す際に、
314
318
 
315
319
  masterブランチと差分を取るために、現在Pull Requestをしているブランチからブランチを切って、その内容を引き継ぎ、masterブランチと差分をとってPull Requestをし直すという認識であっているのでしょうか?

2

glogar

2019/11/28 12:25

投稿

yumetodo
yumetodo

スコア5850

test CHANGED
@@ -264,10 +264,52 @@
264
264
 
265
265
 
266
266
 
267
+ もうすこし視覚的にわかりやすい確認方法も試してみましょう。
268
+
269
+
270
+
271
+ ```
272
+
273
+ $ git log --oneline --graph --all --remotes
274
+
275
+ * 47b4778 (HEAD -> master) Merge branch 'pr'
276
+
277
+ |\
278
+
279
+ | * 9e8cb91 (pr) bbb
280
+
281
+ * | 241309b ccc
282
+
283
+ |/
284
+
285
+ * 41e0281 init commit
286
+
267
287
  ---
268
288
 
269
289
 
270
290
 
291
+ このようにtreeが分岐していることがわかると思います。余談ですが
292
+
293
+
294
+
295
+ ```
296
+
297
+ alias glo='git log --oneline'
298
+
299
+ alias glog='git log --oneline --graph'
300
+
301
+ alias gloga='git log --oneline --graph --all'
302
+
303
+ alias glogar='git log --oneline --graph --all --remotes'
304
+
305
+ ```
306
+
307
+
308
+
309
+ のようなaliasを貼っておくと便利です(上記はbashのaliasの記法)
310
+
311
+
312
+
271
313
  > また、新しくPull Requestを作り直す際に、
272
314
 
273
315
  masterブランチと差分を取るために、現在Pull Requestをしているブランチからブランチを切って、その内容を引き継ぎ、masterブランチと差分をとってPull Requestをし直すという認識であっているのでしょうか?

1

実験

2019/11/28 12:24

投稿

yumetodo
yumetodo

スコア5850

test CHANGED
@@ -12,6 +12,262 @@
12
12
 
13
13
 
14
14
 
15
+ 試しにごく小さなrepoを作って検証してみましょう。
16
+
17
+
18
+
19
+ ```
20
+
21
+ $ mkdir 226145
22
+
23
+ $ cd 226145
24
+
25
+ $ git init
26
+
27
+ Initialized empty Git repository in /home/yumetodo/226145/.git/
28
+
29
+ $ echo "aaa" > foo.txt
30
+
31
+ $ git add .
32
+
33
+ $ git commit -m "init commit"
34
+
35
+ [master (root-commit) 41e0281] init commit
36
+
37
+ 1 file changed, 1 insertion(+)
38
+
39
+ create mode 100644 foo.txt
40
+
41
+ $ git checkout -b pr
42
+
43
+ Switched to a new branch 'pr'
44
+
45
+ $ echo "bbb" >> foo.txt
46
+
47
+ $ git add .
48
+
49
+ $ git commit -m "bbb"
50
+
51
+ [pr 9e8cb91] bbb
52
+
53
+ 1 file changed, 1 insertion(+)
54
+
55
+ $ git checkout master
56
+
57
+ Switched to branch 'master'
58
+
59
+ $ echo "ccc" >> foo.txt
60
+
61
+ $ git add .
62
+
63
+ $ git commit -m "ccc"
64
+
65
+ [master 241309b] ccc
66
+
67
+ 1 file changed, 1 insertion(+)
68
+
69
+ $ git merge pr
70
+
71
+ Auto-merging foo.txt
72
+
73
+ CONFLICT (content): Merge conflict in foo.txt
74
+
75
+ Automatic merge failed; fix conflicts and then commit the result.
76
+
77
+ $ git status
78
+
79
+ On branch master
80
+
81
+ You have unmerged paths.
82
+
83
+ (fix conflicts and run "git commit")
84
+
85
+ (use "git merge --abort" to abort the merge)
86
+
87
+
88
+
89
+ Unmerged paths:
90
+
91
+ (use "git add <file>..." to mark resolution)
92
+
93
+ both modified: foo.txt
94
+
95
+
96
+
97
+ no changes added to commit (use "git add" and/or "git commit -a")
98
+
99
+ $ vim foo.txt
100
+
101
+ $ git add foo.txt
102
+
103
+ $ git commit
104
+
105
+ [master 47b4778] Merge branch 'pr'
106
+
107
+ $ git log
108
+
109
+ commit 47b47784bded011fd2fc995dfdf65938fd222ebd (HEAD -> master)
110
+
111
+ Merge: 241309b 9e8cb91
112
+
113
+ Author: yumetodo <yume-wikijp@live.jp>
114
+
115
+ Date: Thu Nov 28 21:09:59 2019 +0900
116
+
117
+
118
+
119
+ Merge branch 'pr'
120
+
121
+
122
+
123
+ Conflicts:
124
+
125
+ foo.txt
126
+
127
+
128
+
129
+ commit 241309baec09724206792951ff1d39695bd6931e
130
+
131
+ Author: yumetodo <yume-wikijp@live.jp>
132
+
133
+ Date: Thu Nov 28 21:09:10 2019 +0900
134
+
135
+
136
+
137
+ ccc
138
+
139
+
140
+
141
+ commit 9e8cb91bcf73065aab165148fb57c470f03d66e3 (pr)
142
+
143
+ Author: yumetodo <yume-wikijp@live.jp>
144
+
145
+ Date: Thu Nov 28 21:08:38 2019 +0900
146
+
147
+
148
+
149
+ bbb
150
+
151
+
152
+
153
+ commit 41e02818637789a9b987efd232ce93f56c5aa348
154
+
155
+ Author: yumetodo <yume-wikijp@live.jp>
156
+
157
+ Date: Thu Nov 28 21:07:57 2019 +0900
158
+
159
+
160
+
161
+ init commit
162
+
163
+ ```
164
+
165
+
166
+
167
+ こんなふうにrepoを造ったとき、merge commitは`47b47784bded011fd2fc995dfdf65938fd222ebd`ですよね。こいつの情報を見てみると
168
+
169
+
170
+
171
+ ```
172
+
173
+ $ git show 47b47784bded011fd2fc995dfdf65938fd222ebd
174
+
175
+ commit 47b47784bded011fd2fc995dfdf65938fd222ebd (HEAD -> master)
176
+
177
+ Merge: 241309b 9e8cb91
178
+
179
+ Author: yumetodo <yume-wikijp@live.jp>
180
+
181
+ Date: Thu Nov 28 21:09:59 2019 +0900
182
+
183
+
184
+
185
+ Merge branch 'pr'
186
+
187
+
188
+
189
+ Conflicts:
190
+
191
+ foo.txt
192
+
193
+
194
+
195
+ diff --cc foo.txt
196
+
197
+ index 959479a,dbee026..0012ca8
198
+
199
+ --- a/foo.txt
200
+
201
+ +++ b/foo.txt
202
+
203
+ @@@ -1,2 -1,2 +1,4 @@@
204
+
205
+ aaa
206
+
207
+ +ccc
208
+
209
+ + bbb
210
+
211
+ ++
212
+
213
+ ```
214
+
215
+
216
+
217
+ 一方、merge commitではないcommitを適当に見てみましょう。
218
+
219
+
220
+
221
+ ```
222
+
223
+ $ git show 241309baec09724206792951ff1d39695bd6931e
224
+
225
+ commit 241309baec09724206792951ff1d39695bd6931e
226
+
227
+ Author: yumetodo <yume-wikijp@live.jp>
228
+
229
+ Date: Thu Nov 28 21:09:10 2019 +0900
230
+
231
+
232
+
233
+ ccc
234
+
235
+
236
+
237
+ diff --git a/foo.txt b/foo.txt
238
+
239
+ index 72943a1..959479a 100644
240
+
241
+ --- a/foo.txt
242
+
243
+ +++ b/foo.txt
244
+
245
+ @@ -1 +1,2 @@
246
+
247
+ aaa
248
+
249
+ +ccc
250
+
251
+ ```
252
+
253
+
254
+
255
+ merge commitのときのみ
256
+
257
+
258
+
259
+ > Merge: 241309b 9e8cb91
260
+
261
+
262
+
263
+ というのが確認できましたね。一方でmerge commitのコミットメッセージは自由に設定できることも確認できたと思います。
264
+
265
+
266
+
267
+ ---
268
+
269
+
270
+
15
271
  > また、新しくPull Requestを作り直す際に、
16
272
 
17
273
  masterブランチと差分を取るために、現在Pull Requestをしているブランチからブランチを切って、その内容を引き継ぎ、masterブランチと差分をとってPull Requestをし直すという認識であっているのでしょうか?