128
80

More than 1 year has passed since last update.

[git] rebaseが完了できない現象("--continue"を飛ばしてしまったため)の解消手順

Last updated at Posted at 2018-09-09

rebaseでハマりました。
自力でなんとか解消できたのですが、ネットで情報を探せずに苦労したのでシェアします。
認識違いがありましたらコメントください。:bow_tone1:

現象

rebaseでコンフリクトが発生して、手作業で解消して、git rebase --continueを実行したら、以下のようなレスポンスが…

$ git rebase --continue
Applying: {コメント}
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.

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 statusを実行すると以下のようなレスポンスで、にっちもさっちも行かない状態になってしまいました。

$ git status
On branch {作業ブランチ}
You are currently rebasing branch '{作業ブランチ}' on '{sha1値}'.
  (all conflicts fixed: run "git rebase --continue")

nothing to commit, working tree clean

正しくは、

【正解】
$ git rebase {ベースブランチ}
(コンフリクトを解消)
$ git add {パラメータ}
$ git rebase --continue
$ git commit {パラメータ}
という手順でコマンドを実行すべきところ、

【誤り】
$ git rebase {ベースブランチ}
(コンフリクトを解消)
$ git add {パラメータ}
$ git commit {パラメータ}
$ git rebase --continue

という流れで実行してしまったことが原因のようです。

解消手順

git rebase -helpを実行してオプションを調べてみたところ、

--quit                abort but keep HEAD where it is

--quitというオプションで、rebaseを中断しつつ、HEADは維持するとのこと。

ということで、

git rebase --quitを実行してみたら、コンフリクト解消の作業状態を維持しつつ、rebaseはキャンセルできました!

この後、一連のコマンドを実行し直して、無事にrebaseが完了しました。

なお、--abortオプションを指定してしまうと、コンフリクト解消の作業状態はなくなってしまいます。

128
80
2

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
128
80