yashinomi / sysdev2020_advanced

0 stars 0 forks source link

Class 3. Exercise 6. log #11

Closed yashinomi closed 4 years ago

yashinomi commented 4 years ago

マージ、コミット、そしてコンフリクト

yashinomi commented 4 years ago

最初のマージ。コミットメッセージを要求され、無事成功。

$ git checkout master
Switched to branch 'master'
$ git merge --no-ff br-a
Merge made by the 'recursive' strategy.
 fuga.txt  | 1 +
 hoge.txt  | 1 +
 readme.md | 1 +
 3 files changed, 3 insertions(+)
 create mode 100644 fuga.txt
 create mode 100644 hoge.txt
>>> elapsed time 39s 
yashinomi commented 4 years ago

br-aに戻る

$ git checkout br-a
Switched to branch 'br-a'
yashinomi commented 4 years ago

lorem.txtの6行目に加筆してコミット。

$ vim lorem.txt
$ git add lorem.txt
$ git commit -m "add 4 elements"
[br-a 9e6d64d] add 4 elements
 1 file changed, 2 insertions(+)
yashinomi commented 4 years ago

master に戻る。lorem.txtの6行目に別の加筆を行う。コミット。

$ git checkout master 
Switched to branch 'master'
$ vim lorem.txt
$ git add lorem.txt
$ git commit -m "add 5 elements"
[master bd26177] add 5 elements
 1 file changed, 2 insertions(+)
yashinomi commented 4 years ago

コンフリクトさせる。

$ git merge --no-ff br-a
Auto-merging lorem.txt
CONFLICT (content): Merge conflict in lorem.txt
Automatic merge failed; fix conflicts and then commit the result.
yashinomi commented 4 years ago

手動修正を行う。加筆した行を合体させて、再度コミット。コンフリクトの解消に成功?

$ vim lorem.txt 
$ 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:   lorem.txt

no changes added to commit (use "git add" and/or "git commit -a")
$ git add lorem.txt
$ git commit -m "fix conflict"
[master c7a420a] fix conflict
yashinomi commented 4 years ago

git log の最新あたりを表示。

$ git log --graph --all --decorate=full
*   commit c7a420abe4b3d34b829d755c4c18b34cefc60783 (HEAD -> refs/heads/master)
|\  Merge: bd26177 9e6d64d
| | Author: 
| | Date:   Fri Oct 23 16:08:39 2020 +0900
| | 
| |     fix conflict
| | 
| * commit 9e6d64d795c39d9b5ae6aa73abc8011522a4783e (refs/heads/br-a)
| | Author: 
| | Date:   Fri Oct 23 16:02:39 2020 +0900
| | 
| |     add 4 elements
| | 
* | commit bd26177d77388ee2b7b7468ba40da459839ceca1
| | Author: 
| | Date:   Fri Oct 23 16:05:42 2020 +0900
| | 
| |     add 5 elements
| | 
* | commit 0965d363dd7056b3d2612490eee70ef14c99a695
|\| Merge: cbae756 585e277
| | Author:
| | Date:   Fri Oct 23 15:52:44 2020 +0900
| | 
| |     Merge branch 'br-a'
| |     this is to test the merge functionality
| | 
| * commit 585e2772452bd4a408dd24158752bc209902ef06
| | Author: 
| | Date:   Fri Oct 23 15:37:03 2020 +0900
| | 
| |     add note