Gitの練習3
gitのmergeでコンフリクトした場合の対処
- git fetch
- 変更をローカルに持ってくる?
- git merge origin
- originとマージ。
- オートマージでうまく行かなかった場合にはこんなメッセージ
$ git merge origin Auto-merging memo.txt CONFLICT (content): Merge conflict in memo.txt Automatic merge failed; fix conflicts and then commit the result.
- コンフリクトしていてマージできなかったよと言っているので、対象のファイルを確認。
- 「<<<<<<< HEAD」やら「>>>>>>> origin」、「======= 」やらがコンフリクトした所を示してるので、直接ファイルを修正。
- git status
- 現在の状況を確認
# Unmerged paths: # (use "git add <file>..." to mark resolution) # # both modified: memo.txt
「両方修正済み」って事かな?
- git add .
- コンフリクトが解決していることを通知。
- git status
- 確認
# Changes to be committed: # # modified: README.md # modified: memo.txt
「変更がコミットされたよ!」って事かな。
実際の作業手順!!
概要
ちょっとづつ使い方がわかってきたのでまとめてみる。
- branchを作成
- git checkout -b test2
- branchで作業
- branchにコミット
- git add memo.txt
- git commit -m "作業内容。"
- branchの内容をmasterにマージ
- git checkout master
- git merge test2
- masterをpush
- git push
- branchの削除
- git branch -D test2
これで作業が捗るはず。
その他コマンド
本当にbranch消していいかの確認
- git diff master test3 memo.txt
git diffで、異なるブランチの異なるファイルを比較する方法 · DQNEO起業日記
リモートブランチの削除
- git push origin :test