ツナワタリマイライフ

日常ネタから技術ネタ、音楽ネタまで何でも書きます。

「エンジニアのためのgit教科書」からgitの内部構造を学ぶ 実践編その2

はじめに

前回に引き続き、エンジニアのgit教科書から中級編の内容をなぞっていきます。

git init —bare

正直説明見てもベアリポジトリの意味がよくわかりませんでした。ワーキングディレクトリを持たない、つまりファイル編集ができないリポジトリということですね。普段あまり意識しませんが、中央リポジトリ(gitlabやgithub)はbareリポジトリが望ましそうです。クライアント側でbareリポジトリを持つメリットは思いつきませんでした。

diffをとってみましょう。

> ~/g/git_study diff -r git_init git_init_bare/                            12:08:42
diff -r git_init/.git/config git_init_bare/.git/config
4,5c4
<  bare = false
<  logallrefupdates = true
---
>  bare = true

gitconfigの、bareかどうかの値と、logallrefupdatesが増えていますね。

manを見てみます。

       core.logAllRefUpdates
           Enable the reflog. Updates to a ref <ref> is logged to the file
           "$GIT_DIR/logs/<ref>", by appending the new and old SHA-1, the
           date/time and the reason of the update, but only when the file
           exists. If this configuration variable is set to true, missing
           "$GIT_DIR/logs/<ref>" file is automatically created for branch
           heads (i.e. under refs/heads/), remote refs (i.e. under
           refs/remotes/), note refs (i.e. under refs/notes/), and the
           symbolic ref HEAD.

           This information can be used to determine what commit was the
           tip of a branch "2 days ago".

           This value is true by default in a repository that has a working
           directory associated with it, and false by default in a bare
           repository.

ベアリポジトリではfalse、そうでない場合はtrueがデフォルトのようだ。というか、指定しない場合のデフォルトはfalseで、通常trueが入ってると思えばいいのかな。

reflogとはHEADの動きに関する履歴で、それを有効するオプションのようだ。bareリポジトリでは不要と判断されているんですね。

参考

git remote

正直常にcloneからはじまるのでremoteコマンドめったに使わないんですよね。remoteに追加してdiffをみてみましょう。

> ~/g/g/git_init on master ⨯ 
git remote add origin https://github.com/takeshe12/git_study.git
⋊> ~/g/g/git_init on master ⨯ diff -r .git_bak/ .git                        12:21:59
diff -r .git_bak/config .git/config
7a8,10
> [remote "origin"]
>  url = https://github.com/takeshe12/git_study.git
>  fetch = +refs/heads/*:refs/remotes/origin/*

はい、configにremoteが追加されましたね。

git push

それでは適当に変更を加えて、remoteにpushしてみましょう。push前とpush後でdiffを見てみます。

> ~/g/g/git_init on master ⨯ touch test                                    12:23:44> ~/g/g/git_init on master ⨯ git add test                                  12:23:46> ~/g/g/git_init on master ⨯ git commit -m "test commit"                   12:23:53
[master (root-commit) 8ac0e4f] test commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test

コミットしたあと、pushします。

> ~/g/g/git_init on master  git push                                       12:24:07
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

しかし、単にpushしようとすると怒られます。ローカルのmasterに対応するupstreamを指定しなさいよということです。

> ~/g/g/git_init on master  git push --set-upstream origin master          12:24:40
Counting objects: 3, done.
Writing objects: 100% (3/3), 206 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/takeshe12/git_study.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

追跡ブランチが設定されました。

> ~/g/g/git_init on master ⨯ diff -r .git_bak/ .git/                       12:28:06
diff -r .git_bak/config .git/config
10a11,13
> [branch "master"]
>  remote = origin
>  merge = refs/heads/master
Only in .git/logs/refs: remotes
Only in .git/refs: remotes

configにbranch masterという項目が追加されました。refsにremotesが増えました。中を見てみましょう。

> ~/g/g/git_init on master ⨯ cat .git/refs/remotes/origin/master           12:30:24
9ac0f722fe53561aaf99a2858ab0c39d46e93477

remoteのrefが差しているのはcommitオブジェクトですね。

> ~/g/g/git_init on master ⨯ git cat-file -t 9ac0f7                        12:30:34
commit
⋊> ~/g/g/git_init on master ⨯ git cat-file -p 9ac0f7                        12:31:02
tree f05af273ba36fe5176e5eaab349661a56b3d27a0
author kondo takeshi <take.she12@gmail.com> 1502422008 +0900
committer kondo takeshi <take.she12@gmail.com> 1502422008 +0900

test commit

git clone

ではこのリモートのリポジトリをcloneしてみましょう。

> ~/g/git_study diff -r git_init/ git_study/                               12:33:27
Only in git_init/.git: COMMIT_EDITMSG
Binary files git_init/.git/index and git_study/.git/index differ
diff -r git_init/.git/logs/HEAD git_study/.git/logs/HEAD
1c1
< 0000000000000000000000000000000000000000 9ac0f722fe53561aaf99a2858ab0c39d46e93477 kondo takeshi <take.she12@gmail.com> 1502422008 +0900  commit (initial): test commit
---
> 0000000000000000000000000000000000000000 9ac0f722fe53561aaf99a2858ab0c39d46e93477 kondo takeshi <take.she12@gmail.com> 1502422351 +0900  clone: from https://github.com/takeshe12/git_study.git
diff -r git_init/.git/logs/refs/heads/master git_study/.git/logs/refs/heads/master
1c1
< 0000000000000000000000000000000000000000 9ac0f722fe53561aaf99a2858ab0c39d46e93477 kondo takeshi <take.she12@gmail.com> 1502422008 +0900  commit (initial): test commit
---
> 0000000000000000000000000000000000000000 9ac0f722fe53561aaf99a2858ab0c39d46e93477 kondo takeshi <take.she12@gmail.com> 1502422351 +0900  clone: from https://github.com/takeshe12/git_study.git
Only in git_study/.git/logs/refs/remotes/origin: HEAD
Only in git_init/.git/logs/refs/remotes/origin: master
Only in git_study/.git: packed-refs
Only in git_study/.git/refs/remotes/origin: HEAD
Only in git_init/.git/refs/remotes/origin: master

まったく同じかと思ったんですが結構違いますね。直前のCOMMITMESSAGEがない。HEADのreflogがcloneかそうでないかの違いがあります。

git tag

次はタグをつけてみます。

> ~/g/g/git_init on master ⨯ git tag -a "v1.0" -m "version 1.0"            12:36:54> ~/g/g/git_init on master ⨯ diff -r .git_bak/ .git/                       12:37:05
Only in .git/objects: b3
Only in .git/refs/tags: v1.0

タグオブジェクトが作られていますね。内容を確認しましょう。

> ~/g/g/git_init on master ⨯ 
git cat-file -t b3587da3d2f4854f53580867b013189b793323db 
tag
⋊> ~/g/g/git_init on master ⨯ 
git cat-file -p b3587da3d2f4854f53580867b013189b793323db 
object 
type commit
tag v1.0
tagger kondo takeshi <take.she12@gmail.com> 1502422625 +0900

version 1.0

tagオブジェクトはcommitオブジェクトを参照しています。最新コミットを参照していますね。

> ~/g/g/git_init on master ⨯ git cat-file -t 9ac0f722fe53561aaf99a2858ab0c39d46e93477                                14:58:15
commit
⋊> ~/g/g/git_init on master ⨯ git cat-file -p 9ac0f722fe53561aaf99a2858ab0c39d46e93477                                14:58:52
tree f05af273ba36fe5176e5eaab349661a56b3d27a0
author kondo takeshi <take.she12@gmail.com> 1502422008 +0900
committer kondo takeshi <take.she12@gmail.com> 1502422008 +0900

test commit

git branch

次はbranchの作成です。

> ~/g/g/git_init on master ⨯ git branch                                                                              15:14:17
* master
⋊> ~/g/g/git_init on master ⨯ git branch develop                                                                      15:14:19> ~/g/g/git_init on master ⨯ git branch                                                                              15:14:25
  develop
* master
⋊> ~/g/g/git_init on master ⨯ diff -r .git_bak/ .git/                                                                 15:14:28
Only in .git/logs/refs/heads: develop
Only in .git/refs/heads: develop

refsとlogsにdevelopが作成されています。

> ~/g/g/git_init on master ⨯ cat .git/logs/refs/heads/develop                                                        15:14:33
0000000000000000000000000000000000000000 9ac0f722fe53561aaf99a2858ab0c39d46e93477 kondo takeshi <take.she12@gmail.com> 1502432065 +0900 branch: Created from master

logsにはmasterからbranchされたことが記載されています。

> ~/g/g/git_init on master ⨯ cat .git/refs/heads/develop                                                             15:15:45
9ac0f722fe53561aaf99a2858ab0c39d46e93477

refsにはコミットオブジェクトが参照されていますね。

つまりブランチの実態はコミットへの参照ということがわかりました。

git checkout

developブランチにcheckoutしてみましょう。

> ~/g/g/git_init on master ⨯ git checkout develop                                                                    15:18:19
Switched to branch 'develop'> ~/g/g/git_init on develop ⨯ diff -r .git_bak/ .git/                                                                15:18:24
diff -r .git_bak/HEAD .git/HEAD
1c1
< ref: refs/heads/master
---
> ref: refs/heads/develop
diff -r .git_bak/logs/HEAD .git/logs/HEAD
1a2
> 9ac0f722fe53561aaf99a2858ab0c39d46e93477 9ac0f722fe53561aaf99a2858ab0c39d46e93477 kondo takeshi <take.she12@gmail.com> 1502432304 +0900   checkout: moving from master to develop

HEADの参照がdevelopに変わりました。logにcheckoutしたlogが増えていますね。

reflogで確認できます。

> ~/g/g/git_init on develop ⨯ git reflog                                                                             15:18:30
9ac0f72 HEAD@{0}: checkout: moving from master to develop
9ac0f72 HEAD@{1}: commit (initial): test commit

git mv

ファイル名を変更します。

> ~/g/g/git_init on develop ⨯ git mv test mv_test                                                                    15:24:01> ~/g/g/git_init on develop ⨯ diff -r .git_bak/ .git/                                                                15:24:08
Binary files .git_bak/index and .git/index differ

indexが変わっただけでした。

これをコミットしてみましょう。

> ~/g/g/git_init on develop ⨯ git commit -m "mv test"                                                                15:25:39
[develop 0e6acf4] mv test
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename test => mv_test (100%)> ~/g/g/git_init on develop ⨯ diff -r .git_bak/ .git/                                                                15:25:50
diff -r .git_bak/COMMIT_EDITMSG .git/COMMIT_EDITMSG
1c1
< test commit
---
> mv test
Binary files .git_bak/index and .git/index differ
diff -r .git_bak/logs/HEAD .git/logs/HEAD
2a3
> 9ac0f722fe53561aaf99a2858ab0c39d46e93477 0e6acf4abacc6914cb47e1b787a47cd0a7f76e73 kondo takeshi <take.she12@gmail.com> 1502432750 +0900   commit: mv test
diff -r .git_bak/logs/refs/heads/develop .git/logs/refs/heads/develop
1a2
> 9ac0f722fe53561aaf99a2858ab0c39d46e93477 0e6acf4abacc6914cb47e1b787a47cd0a7f76e73 kondo takeshi <take.she12@gmail.com> 1502432750 +0900   commit: mv test
Only in .git/objects: 0e
Only in .git/objects: 2b
diff -r .git_bak/refs/heads/develop .git/refs/heads/develop
1c1
< 9ac0f722fe53561aaf99a2858ab0c39d46e93477
---
> 0e6acf4abacc6914cb47e1b787a47cd0a7f76e73

直近のコミットメッセージであるCOMMITMASSAGEは当然変わりますね。また、logも追加されました。新しく2つオブジェクトが追加されています。

1つはコミットオブジェクトです。

> ~/g/g/git_init on develop ⨯ git cat-file -t 0e6acf                                                                 15:27:30
commit
⋊> ~/g/g/git_init on develop ⨯ git cat-file -p 0e6acf                                                                 15:27:46
tree 2b78e1ae5a68db3ca8755f185b87ac5cf8b47a85
parent 9ac0f722fe53561aaf99a2858ab0c39d46e93477
author kondo takeshi <take.she12@gmail.com> 1502432750 +0900
committer kondo takeshi <take.she12@gmail.com> 1502432750 +0900

mv test

もう1つはtreeオブジェクトです。

> ~/g/g/git_init on develop ⨯ git cat-file -t 2b78e1                                                                 15:27:48
tree
⋊> ~/g/g/git_init on develop ⨯ git cat-file -p 2b78e1                                                                 15:28:27
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391   mv_test

今回はファイルないように変更はないのでblobオブジェクトは変化がありません。treeオブジェクトとcommitオブジェクトでmvを表現していますね。

ちなみにコミットオブジェクトがもつparentは何を差しているのでしょうか。

> ~/g/g/git_init on develop ⨯ git cat-file -t 9ac0f7                                                                 15:30:28
commit
⋊> ~/g/g/git_init on develop ⨯ git cat-file -p 9ac0f7                                                                 15:30:32
tree f05af273ba36fe5176e5eaab349661a56b3d27a0
author kondo takeshi <take.she12@gmail.com> 1502422008 +0900
committer kondo takeshi <take.she12@gmail.com> 1502422008 +0900

test commit

コミットオブジェクトです。1つ前のコミットをparentとして差しているんですね。

> ~/g/g/git_init on develop ⨯ git log                                                                                15:30:35
commit 0e6acf4abacc6914cb47e1b787a47cd0a7f76e73
Author: kondo takeshi <take.she12@gmail.com>
Date:   Fri Aug 11 15:25:50 2017 +0900

    mv test

commit 9ac0f722fe53561aaf99a2858ab0c39d46e93477
Author: kondo takeshi <take.she12@gmail.com>
Date:   Fri Aug 11 12:26:48 2017 +0900

    test commit

ちなみにファイルに変更があった場合は新しいblobオブジェクトが作成され、参照されることになります。

git merge

developブランチでは最初のコミットのあと、mvと、内容を修正したコミットがあります。

> ~/g/g/git_init on develop ⨯ git log --oneline                                                                      15:35:10
8008476 change test file
0e6acf4 mv test
9ac0f72 test commit

masterにcheckoutしてみましょう。

> ~/g/g/git_init on develop ⨯ git checkout master                                                                    15:35:15
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
⋊> ~/g/g/git_init on master ⨯ git log --oneline                                                                       15:36:14
9ac0f72 test commit

masterは最初のコミットのみです。この状態でmergeして、差分を見てみましょう。

> ~/g/g/git_init on master ⨯ git merge develop                                                                       15:36:48
Updating 9ac0f72..8008476
Fast-forward
 mv_test | 1 +
 test    | 0
 2 files changed, 1 insertion(+)
 create mode 100644 mv_test
 delete mode 100644 test> ~/g/g/git_init on master ⨯ diff -r .git_bak/ .git/                                                                 15:37:21
Only in .git/: ORIG_HEAD
Binary files .git_bak/index and .git/index differ
diff -r .git_bak/logs/HEAD .git/logs/HEAD
5a6
> 9ac0f722fe53561aaf99a2858ab0c39d46e93477 80084768599bd0852fa0bb1ff18e3ccd138c2721 kondo takeshi <take.she12@gmail.com> 1502433441 +0900   merge develop: Fast-forward
diff -r .git_bak/logs/refs/heads/master .git/logs/refs/heads/master
1a2
> 9ac0f722fe53561aaf99a2858ab0c39d46e93477 80084768599bd0852fa0bb1ff18e3ccd138c2721 kondo takeshi <take.she12@gmail.com> 1502433441 +0900   merge develop: Fast-forward
diff -r .git_bak/refs/heads/master .git/refs/heads/master
1c1
< 9ac0f722fe53561aaf99a2858ab0c39d46e93477
---
> 80084768599bd0852fa0bb1ff18e3ccd138c2721

⋊> ~/g/g/git_init on master ⨯ git log --oneline                                                                       15:37:30
8008476 change test file
0e6acf4 mv test
9ac0f72 test commit

ORIG_HEADというファイルが作成されました。その名の通り、1つ前にHEADが差していたコミットを差しています。

> ~/g/g/git_init on master ⨯ cat .git/ORIG_HEAD                                                                      15:38:10
9ac0f722fe53561aaf99a2858ab0c39d46e93477
⋊> ~/g/g/git_init on master ⨯ git log --oneline                                                                       15:41:02
8008476 change test file
0e6acf4 mv test
9ac0f72 test commit

ところで今回はmergeコミットが作成されていません。fast-forwardとかいてあるとおり、元のmasterとdevelopで差分がないので、単純に先送りする形でmergeが行われたようです。

参考:ブランチの統合【ブランチ】 | サルでもわかるGit入門 〜バージョン管理を使いこなそう〜 | どこでもプロジェクト管理バックログ

では分岐するパターンを見てみましょう。master、developそれぞれに別のコミットを行いました。

> ~/g/g/git_init on master ⨯ git log --oneline                                                                       15:43:11
e7095b5 add test2 to master
8008476 change test file
0e6acf4 mv test
9ac0f72 test commit

⋊> ~/g/g/git_init on develop ⨯ git log --oneline                                                                      15:43:55
78b981a update mv_test to develop
8008476 change test file
0e6acf4 mv test
9ac0f72 test commit

mergeしてみましょう。

> ~/g/g/git_init on master ⨯ git merge develop                                                                       15:48:20
Merge made by the 'recursive' strategy.
 mv_test | 1 +
 1 file changed, 1 insertion(+)

mergeコミットが作成されたので、メッセージ入力を促されます。

  1 Merge branch 'develop'
  2 
  3 # Please enter a commit message to explain why this merge is necessary,
  4 # especially if it merges an updated upstream into a topic branch.
  5 #
  6 # Lines starting with '#' will be ignored, and an empty message aborts
  7 # the commit.
~                   

今回はrecursive戦略が取られたようです。gitのマージ戦略はあとで取り上げるとして、差分を見ていきましょう。

> ~/g/g/git_init on master ⨯ diff -r .git_bak/ .git/                                                                 16:09:51
diff -r .git_bak/ORIG_HEAD .git/ORIG_HEAD
1c1
< 9ac0f722fe53561aaf99a2858ab0c39d46e93477
---
> e7095b5a3636bb36f8bd60680832fe35213dfb19
Binary files .git_bak/index and .git/index differ
diff -r .git_bak/logs/HEAD .git/logs/HEAD
10a11
> e7095b5a3636bb36f8bd60680832fe35213dfb19 ec6a338ce5cb17538e274e1087a2aec6d4c34019 kondo takeshi <take.she12@gmail.com> 1502434106 +0900   merge develop: Merge made by the 'recursive' strategy.
diff -r .git_bak/logs/refs/heads/master .git/logs/refs/heads/master
3a4
> e7095b5a3636bb36f8bd60680832fe35213dfb19 ec6a338ce5cb17538e274e1087a2aec6d4c34019 kondo takeshi <take.she12@gmail.com> 1502434106 +0900   merge develop: Merge made by the 'recursive' strategy.
Only in .git/objects/e2: a1fac55638da3adc5c1a1ef0401300415ced02
Only in .git/objects: ec
diff -r .git_bak/refs/heads/master .git/refs/heads/master
1c1
< e7095b5a3636bb36f8bd60680832fe35213dfb19
---
> ec6a338ce5cb17538e274e1087a2aec6d4c34019

refsはlogの変更はいいとして、2つのオブジェクトが作られています。

> ~/g/g/git_init on master ⨯ git cat-file -t e2a1fa                                                                  16:10:56
tree
⋊> ~/g/g/git_init on master ⨯ git cat-file -p e2a1fa                                                                  16:11:15
100644 blob 884e2cc3e9f6fb0d9df2a316041914095f7012e9   mv_test
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391   test2
⋊> ~/g/g/git_init on master ⨯ git cat-file -t ec6a33                                                                  16:11:17
commit
⋊> ~/g/g/git_init on master ⨯ git cat-file -p ec6a33                                                                  16:11:55
tree e2a1fac55638da3adc5c1a1ef0401300415ced02
parent e7095b5a3636bb36f8bd60680832fe35213dfb19
parent 78b981af7038583efb9b3e19016af18eff702a27
author kondo takeshi <take.she12@gmail.com> 1502434106 +0900
committer kondo takeshi <take.she12@gmail.com> 1502434106 +0900

Merge branch 'develop'

treeオブジェクトとcommitオブジェクトです。マージコミットはparentが2つありますね。2つの親から合流していることを示すのがマージコミットということがわかりました。

merge戦略

recursibleとfast-forwardの戦略がありましたが、他には何があるのでしょうか。

https://git-scm.com/docs/merge-strategies

octopus、ours、subtreeがあり、recursiveがdefaultとありますね。

octopus

This resolves cases with more than two heads, but refuses to do a complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branch.

2つ以上のHEADをマージする戦略。ただし、手作業でのコンフリクト解決はできない。1つ以上のブランチをpullまたはmergeするときのデフォルト戦略である。

ours

This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the ‘recursive’ merge strategy.

ほかのブランチの変更を効果的に無視し、現在のブランチの変更だけを採用する戦略。コンフリクトしたときに片方だけを採用したい場合に使いそうですね。

subtree

This is a modified recursive strategy. When merging trees A and B, if B corresponds to a subtree of A, B is first adjusted to match the tree structure of A, instead of reading the trees at the same level. This adjustment is also done to the common ancestor tree.

ブランチAに対してBが単純なサブツリー、つまりマージ元に新規コミットがない場合は単に遡って同じコミットに合わせる戦略。これは前述のfast-forwardのことのようですね。

git rebase

さぁ、最後rebaseです。初心者には一番気味悪がられるコマンドですが、結構便利なので一度覚えるとかなり使うようになりますね。主にコミットを1つにまとめるときに使っています。

ここではmergeの手段としてのrebaseを見ていきましょう。

現在のグラフは以下のようになっています。

* master
⋊> ~/g/g/git_init on master ⨯ git log --graph --oneline                                                               16:26:38
*   ec6a338 Merge branch 'develop'
|\  
| * 78b981a update mv_test to develop
* | e7095b5 add test2 to master
|/  
* 8008476 change test file
* 0e6acf4 mv test
* 9ac0f72 test commit

この状態で、再度枝分かれを作成しましょう。まずmasterに1コミット。

> ~/g/g/git_init on master ⨯ git commit -m "update to master"                                                        16:27:28
[master 288cf43] update to master
 1 file changed, 1 insertion(+)

次にdevelopへ1コミット

> ~/g/g/git_init on master ⨯ git checkout develop                                                                    16:27:32
Switched to branch 'develop'> ~/g/g/git_init on develop ⨯ git commit -m "update to develop"                                                      16:27:48
[develop a859860] update to develop
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 rebase_test.txt

developブランチで、masterに向けてrebaseを実行します。

> ~/g/g/git_init on develop ⨯ git rebase master                                                                      16:30:07
First, rewinding head to replay your work on top of it...
Applying: update to develop

この状態で差分を見てみましょう。

> ~/g/g/git_init on develop ⨯ git log --graph --oneline                                                              16:30:56
* 89748b7 update to develop
* 288cf43 update to master
*   ec6a338 Merge branch 'develop'
|\  
| * 78b981a update mv_test to develop
* | e7095b5 add test2 to master
|/  
* 8008476 change test file
* 0e6acf4 mv test
* 9ac0f72 test commit

コミットがまっすぐ並びました。

diffをとると、新たに2つのオブジェクトが作成されています。

Only in .git/objects: 89
Only in .git/objects: dc

コミットオブジェクトとツリーオブジェクトです。

> ~/g/g/git_init on develop ⨯ git cat-file -t 89748b                                                                 16:34:29
commit
⋊> ~/g/g/git_init on develop ⨯ git cat-file -p 89748b                                                                 16:34:33
tree dc568b43edd0bb751256a65e3bcfa7dbd03b97ba
parent 288cf4374fad6791ae744c5ac4ef57eec803ff7c
author kondo takeshi <take.she12@gmail.com> 1502436476 +0900
committer kondo takeshi <take.she12@gmail.com> 1502436614 +0900

update to develop

おっと、このコミットは以前はこちらのコミットでした。

> ~/g/g/git_init on develop ⨯ git cat-file -p a859860                                                                16:35:10
tree 7d8604b49710a922ff3e58adb0c6c5f185ccc013
parent 78b981af7038583efb9b3e19016af18eff702a27
author kondo takeshi <take.she12@gmail.com> 1502436476 +0900
committer kondo takeshi <take.she12@gmail.com> 1502436476 +0900

update to develop

rebaseすると新しくコミットが生成されるんですね。parentとtreeが更新されています。

ここまで書いて気づきましたけど、master上でdevelopをrebaseすべきでしたね。

おわりに

branch作成からrebaseまで、一通りのgitコマンドの動きを追いかけることができました。かなりボリューミー。感想としては「だいたい参照のリレー」だなーってところです。うまくできてるなと思いました。