【Git】Merge branch【原因】

  • このエントリーをはてなブックマークに追加

2023年6月26日(月)の時点
gitでよく分かっていないところを書いておく。
git pullしたときに、次のviエディタが起動する。
viエディタが起動したとき、Merge branchと出てきた。


Merge branch 'main' of github.com:reiwa-info-fin-corp/localtime into update
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

不明点
このviエディタはどんなときに出て来る?このviエディタを出そうしたが再現できない。
このviエディタが出てきた、「:wq」(保存終了 wite & quit)をすること。

Merge branchがよく分かっていない。

〇追記20231103
やっとMerge branch出る条件が分かった。
mainブランチとmainブランチ以外のブランチがあり、mainブランチでコミットした後に「git push origin 【mainブランチ以外のブランチ】」する前に「git pull origin main」をすると「Merge branch」となるようだ。github上の【main】と自分のPCの【mainブランチ以外のブランチ】がmergeされるということだな。

git logは次のようなメッセージになる。「Merge branch」と書いてある。


commit 5c2e36851594d4946a431e3227cc82ad95596597
Merge: 4a90a16 f4ceeae
Author: reiwa-info-fin-corp <reiwa.info.fin.corp@gmail.com>
Date:   Sun Jun 25 16:55:25 2023 +0900

    Merge branch 'main' of github.com:reiwa-info-fin-corp/localtime into update

「Showing 0 changed files with 0 additions and 0 deletions.」とgithubに出ているな。
やはり、変更がないにもかかわらず、Merge branchとgit logに出るのか?よく分からないな。

Merge branch ‘main’ of github.com:reiwa-info-fin-corp/localtime into … · reiwa-info-fin-corp/localtime@5c2e368 · GitHub ExternalLink

git pullしたときに「Merge made by the ‘ort’ strategy.」となると、「git log」に「Merge branch」と出るみたいだな。
「Merge made by the ‘ort’ strategy.」は、「’ort’戦略によってマージが行われました。」という意味である。。「ort」は特定のマージ戦略の名前らしい。この辺はよく分からない。
とりあえず、このようなメッセージが出ると覚えておく。


〇〇〇@B-7-PC MINGW64 ~/localtime (update)
$ git pull origin main
From github.com:△△△/localtime
 * branch            main       -> FETCH_HEAD
Merge made by the 'ort' strategy.

〇〇〇@B-7-PC MINGW64 ~/localtime (update)
$ git log
commit 5c2e36851594d4946a431e3227cc82ad95596597 (HEAD -> update)
Merge: 4a90a16 f4ceeae
Author: △△△ <~@gmail.com>
Date:   Sun Jun 25 16:55:25 2023 +0900

    Merge branch 'main' of github.com:△△△/localtime into update

Merge branchが出る原因を解明する。
コミットID(5c2e368)の親コミットIDはコミットID(4a90a16)である。
コミットID(f4ceeae)とコミットID(4a90a16)がマージされる。
結果としてコミットID(5c2e368)のMerge branchになっている。
コミットID(4a90a16)の親コミットIDがコミットID(f4ceeae)だったならば、Merge branchにならなかったと考えられる。


〇〇〇@B-7-PC MINGW64 ~/localtime (main)
$ git log --graph --oneline
*   8002dac (HEAD -> main, tag: v1.0.11, origin/main, origin/HEAD) Merge pull request #12 from △△△/update
|\
| * 60ecb1a (origin/update) [update README.md]
| * 525ee17 [update:package.json,README.md]
|/
*   26a4b73 (tag: v1.0.10) Merge pull request #11 from △△△/update
|\
| * 6490df8 [update:package.json,README.md]
|/
*   a9fad4e (tag: v1.0.9) Merge pull request #10 from △△△/update
|\
| * 05d27d0 [update:package.json]
| * c734531 [update:LocalTime.js]
|/
*   dc5bc1a (tag: v1.0.8) Merge pull request #9 from △△△/update
|\
| * c9cf0f8 [update:package.json]
| * eb5adf8 [update:README.md,LocalTime.js]
|/
*   4e11711 (tag: v1.0.7) Merge pull request #8 from △△△/update
|\
| * b700ae7 [update README.md]
| * 2d048e3 [update README.md,package.json]
|/
*   c06bfb7 (tag: v1.0.6) Merge pull request #7 from △△△/update
|\
| * 1c2f9bf [update README.md]
| * 0487838 [update README.md,package.json]
|/
*   5c996e1 (tag: v1.0.5) Merge pull request #6 from △△△/update
|\
| * 4bad8bc [update README.md]
| * 423cd12 [update README.md,package.json]
|/
*   72936d8 (tag: v1.0.4) Merge pull request #5 from △△△/update
|\
| * 28efad7 [update:package.json]
| *   5c2e368 Merge branch 'main' of github.com:△△△/localtime into update
| |\
| |/
|/|
* |   f4ceeae (tag: v1.0.3) Merge pull request #4 from △△△/update
|\ \
| | * 4a90a16 [update:.gitattributes,LocalTime.js,LocalTime_sample.js,README.md,package.json]
| |/
| * 1f56055 [update README.md,LocalTime.js,package.json]
|/
*   671e93f (tag: v1.0.2) Merge pull request #3 from △△△/update
|\
| * 1ba536f [update README.md,package.json]
|/
*   9952025 (tag: v1.0.1) Merge pull request #2 from △△△/update
|\
| * 6c0badc [update README.md,LocalTime_sample.js,package.json]
|/
*   266c76f (tag: v1.0.0) Merge pull request #1 from △△△/update
|\
| * ef2c982 [update README.md],[add LocalTime.js,LocalTime_sample.js,package.json,.gitattributes]
|/
* 0916720 Initial commit
  • このエントリーをはてなブックマークに追加

SNSでもご購読できます。

コメントを残す

*