コンフリクト … 複数ブラント間で同一ファイルの修正が衝突すること。
別のブランチ third を作成
git checkout -b ブランチ名 で、ブランチの作成と切り替えを同時に行う。
$ git branch
* master
test@test-PC MINGW32 /c/www (master)
$ git checkout -b third
Switched to a new branch 'third'
M index.html
test@test-PC MINGW32 /c/www (third)
$ git branch
master
* third
* master
test@test-PC MINGW32 /c/www (master)
$ git checkout -b third
Switched to a new branch 'third'
M index.html
test@test-PC MINGW32 /c/www (third)
$ git branch
master
* third
index.htmlに <p>あいうえお </p>を追加しコミット
$ git add index.html
test@test-PC MINGW32 /c/www (third)
$ git commit -m "add aiueo to index.html"
[third 987c94e] add aiueo to index.html
1 file changed, 1 insertion(+), 5 deletions(-)
test@test-PC MINGW32 /c/www (third)
$ git status
On branch third
nothing to commit, working tree clean
test@test-PC MINGW32 /c/www (third)
$ git commit -m "add aiueo to index.html"
[third 987c94e] add aiueo to index.html
1 file changed, 1 insertion(+), 5 deletions(-)
test@test-PC MINGW32 /c/www (third)
$ git status
On branch third
nothing to commit, working tree clean
masterブランチに移動
test@test-PC MINGW32 /c/www (third)
$ git checkout master
Switched to branch 'master'
test@test-PC MINGW32 /c/www (master)
$ git checkout master
Switched to branch 'master'
test@test-PC MINGW32 /c/www (master)
index.htmlに <p>かきくけこ </p>を追加しコミット
$ git add index.html
test@test-PC MINGW32 /c/www (master)
$ git commit -m "add kakikukeko to index.html"
[master 8ce179b] add kakikukeko to index.html
1 file changed, 1 insertion(+), 5 deletions(-)
test@test-PC MINGW32 /c/www (master)
$ git status
On branch master
nothing to commit, working tree clean
test@test-PC MINGW32 /c/www (master)
$ git commit -m "add kakikukeko to index.html"
[master 8ce179b] add kakikukeko to index.html
1 file changed, 1 insertion(+), 5 deletions(-)
test@test-PC MINGW32 /c/www (master)
$ git status
On branch master
nothing to commit, working tree clean
マージ実行
$ git merge third
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
自動マージに失敗する。Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
index.htmlを開く
衝突した箇所がコメント付きでマージされている。
(Visual Studio Codeでは、衝突した箇所を認識し「現在の変更を取り込む|入力側の変更を取り込む|両方の変更を取り込む|変更の比較」メニューが表示されるみたい)
ここでは「両方の変更を取り込む」を指定
git statusを見てみる。
$ 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..." to mark resolution)
both modified: index.html
no changes added to commit (use "git add" and/or "git commit -a")
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
both modified: index.html
no changes added to commit (use "git add" and/or "git commit -a")
git addを実行
$ git add index.html
test@test-PC MINGW32 /c/www (master|MERGING)
$ git status
On branch master
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: index.html
test@test-PC MINGW32 /c/www (master|MERGING)
$ git status
On branch master
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: index.html
コミット実行
$ git commit --no-edit
[master 911b796] Merge branch 'third'
test@test-PC MINGW32 /c/www (master)
$ git status
On branch master
nothing to commit, working tree clean
git commitに「--no-edit」を付けないと変なエディタが開く?[master 911b796] Merge branch 'third'
test@test-PC MINGW32 /c/www (master)
$ git status
On branch master
nothing to commit, working tree clean
ログ確認
$ git log --oneline --decorate
911b796 (HEAD -> master) Merge branch 'third'
8ce179b add kakikukeko to index.html
987c94e (third) add aiueo to index.html
911b796 (HEAD -> master) Merge branch 'third'
8ce179b add kakikukeko to index.html
987c94e (third) add aiueo to index.html
0 件のコメント:
コメントを投稿