Kukurukku / Learning

0 stars 1 forks source link

【練習】fetch・merge・confrict #10

Open Kukurukku opened 9 years ago

Kukurukku commented 9 years ago

前提mmブランチをもとに、ローカルにmm_modify1とmm_modify2を作成。

パターン1の手順:両方編集(コンフリクトが起きるように)してmm1の方を先にmmにpush push後mm2にブランチきってfetch してmergeを実行してコンフリクトを起こさせる。 mm1のほうの更新でローカルのmm2の内容を上書きし、(mm2の内容を消す)コンフリクト箇所意外を編集してコミットする

パターン2の手順:両方編集(コンフリクトが起きるように)してmm1の方を先にmmにpush push後mm2にブランチきってfetch してmergeを実行してコンフリクトを起こさせる。 mm2のほうの更新でローカルのmm2の内容を上書きしコミット(リモートのmmブランチで、mm1が更新した内容がmm2で上書きされる予定)

Kukurukku commented 9 years ago

【結果】 p1:git mergetoolでコンフリクトを修正した。

azumaya-no-iMac:branch_fetch_merge_confrict_Test HigashiyaYurie$ git pull Auto-merging branch_fetch_merge_confrict_Test/fetch_merge_confrict_text.txt CONFLICT (content): Merge conflict in branch_fetch_merge_confrict_Test/fetch_merge_confrict_text.txt Automatic merge failed; fix conflicts and then commit the result. azumaya-no-iMac:branch_fetch_merge_confrict_Test HigashiyaYurie$ git status On branch mm_modify2 Your branch and 'origin/mm' have diverged, and have 1 and 1 different commit each, respectively. (use "git pull" to merge the remote branch into yours)

You have unmerged paths. (fix conflicts and run "git commit")

Unmerged paths: (use "git add ..." to mark resolution)

both modified:   fetch_merge_confrict_text.txt

⬇️ azumaya-no-iMac:branch_fetch_merge_confrict_Test HigashiyaYurie$ git mergetool

mergetool上で適用する方の修正をchoose right とか leftとかする。leftがおそらくローカル。

その後git statusがbothからmodified状態になるのでそれをコミットで更新できた

p2:mm_modify2の方の修正をaddでステージングした状態で、名前をつけてstash。

azumaya-no-iMac:branch_fetch_merge_confrict_Test HigashiyaYurie$ git stash save "#10パターン2テスト:mm_modify2の変更状態stash"

remoteからgit fetch とmergeをしてローカルにmm_modify1の修正を取り込んだmmを持ってくる

azumaya-no-iMac:branch_fetch_merge_confrict_Test HigashiyaYurie$ git fetch origin azumaya-no-iMac:branch_fetch_merge_confrict_Test HigashiyaYurie$ git merge origin/mm

そこで、先ほどのstashをポップしてコンフリクトさせ、手動でviで開いて編集。 upstreamとあるのがremoteでstashとあるのがpopしたやつだった。 ちなみに編集後 git statusしてもbothのままなので、addの必要あり。 addするとgit statusで確認するとmodifiedになる。

azumaya-no-iMac:branch_fetch_merge_confrict_Test HigashiyaYurie$ git stash pop stash@{0} Auto-merging branch_fetch_merge_confrict_Test/fetch_merge_confrict_text.txt CONFLICT (content): Merge conflict in branch_fetch_merge_confrict_Test/fetch_merge_confrict_text.txt