gitでmasterにマージする際のメモ - littlestarling/rails_training_hall GitHub Wiki

基本コンセプト

  • 諸説あると思うけどとりあえずはmasterの変更を尊重し、かつ自分の変更を後に追加するという戦略を採る。
  • 並行作業時にこの方法で実施していけば余計なコンフリクトはかなり減るはず
  • この手順はmerge PRボタンでは実施出来ないのでローカルPCで行う

前提

  • 自分のトピックブランチをtopicとする。masterに対してマージする

手順

  • ローカルのmasterを最新にする
 [user@localhost git:topic] git co master
 [user@localhost git:master] git pull
  • topicにrebaseする
 [user@localhost git:master] git co topic
 [user@localhost git:topic] git rebase master
  • この時、CONFLICTが出るようであれば対象ファイルを編集してrebaseを進める。例としてapp/models/item.rbがコンフリクトした場合
 [user@localhost git:topic] vi app/models/item.rb #=> 適宜編集、保存
 [user@localhost git:topic] git add app/models/item.rb
 [user@localhost git:topic] git rebase --continue 
  • 全て完了したらmasterにmergeする
 [user@localhost git:topic] git co master
 [user@localhost git:master] git merge topic #=> rebaseで整理してあるのでここで詰まることはないはず
 [user@localhost git:master] git push origin master
  • github上のPRを手動でcloseする。