SHARE
TWEET

Untitled

a guest Apr 27th, 2018 196 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # 内容は同じだけど履歴は違うけどブランチ master と two-phases を作る
  2. % git init
  3. Initialized empty Git repository in /private/tmp/myrepo/.git/
  4. % touch ab.txt
  5. % git add ab.txt; git commit -m 'a empty file'
  6. [master (root-commit) 7d9d5ea] a empty file
  7.  0 files changed, 0 insertions(+), 0 deletions(-)
  8.  create mode 100644 ab.txt
  9.  
  10. % echo 'A\nB' > ab.txt
  11. % git commit -am 'A and B'
  12. [master c7091de] A and B
  13.  1 files changed, 2 insertions(+), 0 deletions(-)
  14.  
  15. % git checkout -b two-phases HEAD~
  16. % echo 'A' > ab.txt
  17. % git commit -am 'A added'
  18. [two-phases 4cf3183] A added
  19.  1 files changed, 1 insertions(+), 0 deletions(-)
  20. % echo 'B' >> ab.txt
  21. % git commit -am 'B added'
  22. [two-phases 246f617] B added
  23.  1 files changed, 1 insertions(+), 0 deletions(-)
  24.  
  25. # ツリーは一緒
  26. % git cat-file -p master
  27. tree b4077185390b0ff9495a6db2122e9b478c50af08
  28. parent 7d9d5ea99dcdf9e9c270dab09affc6d0c4705e46
  29. author hiratara <hiratara@cpan.org> 1262937776 +0900
  30. committer hiratara <hiratara@cpan.org> 1262937776 +0900
  31.  
  32. A and B
  33.  
  34.  
  35. % git cat-file -p two-phases
  36. tree b4077185390b0ff9495a6db2122e9b478c50af08
  37. parent 4cf31836d3c5069bd5f12c68468369b9dbafaa29
  38. author hiratara <hiratara@cpan.org> 1262937874 +0900
  39. committer hiratara <hiratara@cpan.org> 1262937874 +0900
  40.  
  41. B added
  42.  
  43.  
  44. # コミットのIDは別
  45. % git rev-parse master
  46. c7091de25d27cf53570cd850a72fde5e087aa122
  47.  
  48. % git rev-parse two-phases
  49. 246f6173aec6c82e9fbd2da14f8e9391aa179d15
  50.  
  51.  
  52. # show-branch の結果
  53. % git show-branch master two-phases
  54. ! [master] A and B
  55.  * [two-phases] B added
  56. --
  57.  * [two-phases] B added
  58.  * [two-phases^] A added
  59. +  [master] A and B
  60. +* [two-phases~2] a empty file
  61.  
  62.  
  63. # 全く同じ履歴をshow-branchするとこう
  64. % git show-branch master c7091de25d27
  65. ! [master] A and B
  66.  ! [c7091de25d27] A and B
  67. --
  68. ++ [master] A and B
  69.  
  70. % git show-branch two-phases 246f6173aec
  71. * [two-phases] B added
  72.  ! [246f6173aec] B added
  73. --
  74. *+ [two-phases] B added
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. # 念のため、master と two-phases に another ブランチをマージして show_branch する
  82. % git checkout -b another HEAD~2
  83. Switched to a new branch 'another'
  84. % echo 'C' > c.txt
  85. % git add c.txt; git commit -m "C added"
  86. [another 8fafada] C added
  87.  1 files changed, 1 insertions(+), 0 deletions(-)
  88.  create mode 100644 c.txt
  89.  
  90. % git checkout master
  91. Switched to branch 'master'
  92. % git merge another
  93. Merge made by recursive.
  94.  c.txt |    1 +
  95.  1 files changed, 1 insertions(+), 0 deletions(-)
  96.  create mode 100644 c.txt
  97.  
  98. % git checkout two-phases
  99. Switched to branch 'two-phases'
  100. % git merge another
  101. Merge made by recursive.
  102.  c.txt |    1 +
  103.  1 files changed, 1 insertions(+), 0 deletions(-)
  104.  create mode 100644 c.txt
  105.  
  106. # show-barnch すると履歴は違いそう
  107. % git show-branch master two-phases
  108. ! [master] Merge branch 'another'
  109.  * [two-phases] Merge branch 'another' into two-phases
  110. --
  111.  - [two-phases] Merge branch 'another' into two-phases
  112.  * [two-phases^] B added
  113.  * [two-phases~2] A added
  114. -  [master] Merge branch 'another'
  115. +* [two-phases^2] C added
  116.  
  117. # でも、ツリーのSHA1は同じ
  118. % git cat-file -p master
  119. tree 0ef0528a594b679def8ed8910a66254fa7351adc
  120. parent c7091de25d27cf53570cd850a72fde5e087aa122
  121. parent 8fafadace4f525d2c20d9b29daecb34b3867bf05
  122. author hiratara <hiratara@cpan.org> 1262938703 +0900
  123. committer hiratara <hiratara@cpan.org> 1262938703 +0900
  124.  
  125. Merge branch 'another'
  126.  
  127. % git cat-file -p two-phases
  128. tree 0ef0528a594b679def8ed8910a66254fa7351adc
  129. parent 246f6173aec6c82e9fbd2da14f8e9391aa179d15
  130. parent 8fafadace4f525d2c20d9b29daecb34b3867bf05
  131. author hiratara <hiratara@cpan.org> 1262938741 +0900
  132. committer hiratara <hiratara@cpan.org> 1262938741 +0900
  133.  
  134. Merge branch 'another' into two-phases
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top