ブランチマージ
ブランチマージのさまざまな使用シナリオ:
- 指定したブランチを現在のブランチにマージします
- ブランチマージの競合
- (非)早送りモードのマージ
1.指定したブランチを現在のブランチにマージします
指定したブランチを現在のブランチにマージします
git merge <branch name>
2つ目は、ブランチマージの競合です。
マルチブランチコラボレーションの場合、多くの場合、競合が発生します。
ローカルにはmaster/dev
、同じバージョンを指す2つのブランチがあり、初期状態は同じで、readme.txt
ファイルは1つだけです。
あなたはmaster
上の段落を追加hello master
し、add/git commit
そして、DEVに切り替えて、段落を追加hello dev
し、add/commit
この時点で、ブランチにマージdev
する場合master
、統合は競合が発生します
1.ブランチマージの競合を解決します
git merge <branch name>
ブランチのマージを実行するときに、次の競合が発生した場合は、手動でマージしてから送信する必要があります。
$ git merge feature1
Auto-merging readme.txt
CONFLICT (content): Merge conflict in readme.txt
Automatic merge failed; fix conflicts and then commit the result.
# when resolve the conflict, can exec the following commands:
# git add <files>
# git commit -m "descibe content"
# this command can show the commit graph.
# git log --graph
3.(非)早送りモードの合併
1.ffモード
という名前の新しいブランチを作成し、このブランチにファイルをdev
追加し、readme.txt
マスターに切り替えてマージ操作を実行し、次のコマンドを実行します。
# To execute merege command on master branch.
git merge dev
この時点で開発ブランチが削除されると、ブランチ情報は表示されなくなります。このマージモードは早送りモードと呼ばれます。
2 .-- no-ffモード
--no-ff
モードが使用されている場合は、モードが無効になっていることを意味しff
、以下を実行します。
# To execute merge command using --no-ff mode on master branch.
git merge --no-ff -m "describe message about this commit" dev