55
47

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git rebaseでのブランチ融合でコンフリクト解消

Posted at

問題

git rebaseでブランチを融合しようとしたらエラーが出てしまう。。

$ git branch
  master
* branch

$ git rebase master

First, rewinding head to replay your work on top of it...
Applying: Hoge hoge
Using index info to reconstruct a base tree...
/省略/
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging app/views/articles/hoge
CONFLICT (content): Merge conflict in app/views/hoge
Auto-merging app/views/articles/poge
CONFLICT (content): Merge conflict in app/views/articles/poge
Failed to merge in the changes.
Patch failed at 0001 Poge poge
The copy of the patch that failed is found in:

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

こんな感じのエラーでとにかくコンフリクト。

解決

$ git branch
* (no branch, rebasing sns_button)
master
branch

変なとこいるけど大丈夫。

$ git status

rebase in progress; onto 1234567
You are currently rebasing branch 'branch' on '1234567'.
  (fix conflicts and then run "git rebase --continue")
  (use "git rebase --skip" to skip this patch)
  (use "git rebase --abort" to check out the original branch)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   app/views/page
Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

	both modified:   app/views/hoge
	both modified:   app/views/poge

コンフリクト箇所を修正してaddする。そうすると、

$ git status

rebase in progress; onto 1234567
You are currently rebasing branch 'branch' on '1234567'.
  (all conflicts fixed: run "git rebase --continue")

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   app/views/page
	modified:   app/views/hoge
	modified:   app/views/poge

ここで、rebaseを再開。

$ git rebase --continue

OK!

以下の感じに確認してみてください!

$ git status

On branch branch
nothing to commit, working directory clean

$ git log --oneline -10
55
47
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
55
47

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?