gitのコミットログを見て見ると、
普通の場合 マージした後
Merge pull request #8 from アカウント名/ブランチ名
と表示されますが、 今回は表示されていませんでした。
それはGithub上でmerge commitを作ったときに自動で生成されるcommit messageであって、実のとことmerge commitとは2つの親を持つcommitのことでありメッセージはなんでもいいのです。
試しにごく小さなrepoを作って検証してみましょう。
$ mkdir 226145
$ cd 226145
$ git init
Initialized empty Git repository in /home/yumetodo/226145/.git/
$ echo "aaa" > foo.txt
$ git add .
$ git commit -m "init commit"
[master (root-commit) 41e0281] init commit
1 file changed, 1 insertion(+)
create mode 100644 foo.txt
$ git checkout -b pr
Switched to a new branch 'pr'
$ echo "bbb" >> foo.txt
$ git add .
$ git commit -m "bbb"
[pr 9e8cb91] bbb
1 file changed, 1 insertion(+)
$ git checkout master
Switched to branch 'master'
$ echo "ccc" >> foo.txt
$ git add .
$ git commit -m "ccc"
[master 241309b] ccc
1 file changed, 1 insertion(+)
$ git merge pr
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt
Automatic merge failed; fix conflicts and then commit the result.
$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: foo.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ vim foo.txt
$ git add foo.txt
$ git commit
[master 47b4778] Merge branch 'pr'
$ git log
commit 47b47784bded011fd2fc995dfdf65938fd222ebd (HEAD -> master)
Merge: 241309b 9e8cb91
Author: yumetodo <yume-wikijp@live.jp>
Date: Thu Nov 28 21:09:59 2019 +0900
Merge branch 'pr'
Conflicts:
foo.txt
commit 241309baec09724206792951ff1d39695bd6931e
Author: yumetodo <yume-wikijp@live.jp>
Date: Thu Nov 28 21:09:10 2019 +0900
ccc
commit 9e8cb91bcf73065aab165148fb57c470f03d66e3 (pr)
Author: yumetodo <yume-wikijp@live.jp>
Date: Thu Nov 28 21:08:38 2019 +0900
bbb
commit 41e02818637789a9b987efd232ce93f56c5aa348
Author: yumetodo <yume-wikijp@live.jp>
Date: Thu Nov 28 21:07:57 2019 +0900
init commit
こんなふうにrepoを造ったとき、merge commitは47b47784bded011fd2fc995dfdf65938fd222ebd
ですよね。こいつの情報を見てみると
$ git show 47b47784bded011fd2fc995dfdf65938fd222ebd
commit 47b47784bded011fd2fc995dfdf65938fd222ebd (HEAD -> master)
Merge: 241309b 9e8cb91
Author: yumetodo <yume-wikijp@live.jp>
Date: Thu Nov 28 21:09:59 2019 +0900
Merge branch 'pr'
Conflicts:
foo.txt
diff --cc foo.txt
index 959479a,dbee026..0012ca8
--- a/foo.txt
+++ b/foo.txt
@@@ -1,2 -1,2 +1,4 @@@
aaa
+ccc
+ bbb
++
一方、merge commitではないcommitを適当に見てみましょう。
$ git show 241309baec09724206792951ff1d39695bd6931e
commit 241309baec09724206792951ff1d39695bd6931e
Author: yumetodo <yume-wikijp@live.jp>
Date: Thu Nov 28 21:09:10 2019 +0900
ccc
diff --git a/foo.txt b/foo.txt
index 72943a1..959479a 100644
--- a/foo.txt
+++ b/foo.txt
@@ -1 +1,2 @@
aaa
+ccc
merge commitのときのみ
Merge: 241309b 9e8cb91
というのが確認できましたね。一方でmerge commitのコミットメッセージは自由に設定できることも確認できたと思います。
もうすこし視覚的にわかりやすい確認方法も試してみましょう。
$ git log --oneline --graph --all --remotes
* 47b4778 (HEAD -> master) Merge branch 'pr'
|\
| * 9e8cb91 (pr) bbb
* | 241309b ccc
|/
* 41e0281 init commit
このようにtreeが分岐していることがわかると思います。余談ですが
alias glo='git log --oneline'
alias glog='git log --oneline --graph'
alias gloga='git log --oneline --graph --all'
alias glogar='git log --oneline --graph --all --remotes'
のようなaliasを貼っておくと便利です(上記はbashのaliasの記法)
また、新しくPull Requestを作り直す際に、
masterブランチと差分を取るために、現在Pull Requestをしているブランチからブランチを切って、その内容を引き継ぎ、masterブランチと差分をとってPull Requestをし直すという認識であっているのでしょうか?
そんな必要はなくて、単に現在Pull Requestをしているブランチに新たにcommitしてpushすればいいです
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2019/12/01 07:54 編集
2019/11/29 06:36