[git]入門git 2.ブランチとマージ
重要そうなものには★つけた
ブランチ
ブランチの作成
git branch new_branch
ブランチの切り替え
git checkout new_branch
ブランチ名の変更
git branch -m master mymaster
masterを基にブランチを作成して切り替え
git checkout -b new_branch master
ブランチの削除
git branch -d about2
マージ
直接マージ
現在のブランチにマージ
git merge new_branch
圧縮コミット★
ブランチの変更を1コミットにしてしまう。
新機能やバグフィックス向けらしい。
変更はステージされた状態となるので、その後コミットする。
git merge --squash new_branch
コンフリクトの解消
コンフリクトが発生した場合のメッセージ例
Auto-merging about.html CONFLICT (content): Merge conflict in about.html Automatic merge failed; fix conflicts and then commit the result.
マージツールの起動
git mergetool
マージツールの指定
git config --global merge.tool "tortoisemerge"
マージ後にgit commitすると、自動的にコメントを付けてくれる。
例
Merge branch 'about2' into about