rebase時のコンフリクトの解消して再rebaseする
流れ
1. rebase(ここでコンフリクト発生)
2. コンフリクト対象ファイル確認
3. コンフリクト解消
4. 再rebase
code: (sh)
# rebase
git pull --rebase # リモート設定済みの場合
or
git rebase origin/作業ブランチ # リモート未設定の場合
# コンフリクト対象ファイル確認
git status
...
CONFLICT (content): Merge conflict in コンフリクト対象ファイル
# 再rebase
git rebase --continue
# rebase取り消し
git rebase --abort
コンフリク解消の修正について
エディタでコンフリクトの記号の削除、不要なコードの削除を行い統合後の状態に修正する
PRの内容でrebaseする場合はPRのファイル毎の修正結果を参照して修正を行う
コンフリクトの記号の意味
code:_
<<<<<<< HEAD
古いコード
=======
新しいコード
>>>>>> 修正のコミットID
コマンド例
code: (sh)
❯ git rebase origin/chore/fix-japanese-test-title
...
Auto-merging test/supports/report_helper.rb # コンフリクト対象ファイル
CONFLICT (content): Merge conflict in test/supports/report_helper.rb
error: could not apply 508ba04fd... reportがDBに保存されたことを待ってからReport.last.idするよう修正
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 508ba04fd... reportがDBに保存されたことを待ってからReport.last.idするよう修正
❯ git status
interactive rebase in progress; onto f71722a14 # インタラクティブrebase中
Last commands done (2 commands done):
pick c77a91755 assertでDOMの構築を待つように修正
pick 508ba04fd reportがDBに保存されたことを待ってからReport.last.idするよう修正 # コンフリクトで停止中
No commands remaining.
You are currently rebasing branch 'chore/fix-japanese-test-title' on 'f71722a14'.
(fix conflicts and then run "git rebase --continue") # rebaseの続行
(use "git rebase --skip" to skip this patch) # rebaseのスキップ
(use "git rebase --abort" to check out the original branch) # rebaseの取り消し
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: test/supports/report_helper.rb # コンフリクト対象ファイル
...
❯ git add test/supports/report_helper.rb
❯ git status
interactive rebase in progress; onto f71722a14 # インタラクティブrebase中
Last commands done (2 commands done):
pick c77a91755 assertでDOMの構築を待つように修正
pick 508ba04fd reportがDBに保存されたことを待ってからReport.last.idするよう修正
No commands remaining.
You are currently rebasing branch 'chore/fix-japanese-test-title' on 'f71722a14'.
(all conflicts fixed: run "git rebase --continue") # コンフリクト修正済み
...
❯ git rebase --continue
Successfully rebased and updated refs/heads/chore/fix-japanese-test-title. # rebase完了