Как я могу получить git rebase для завершения после разрешения конфликтов

Я только что попытался отменить некоторые изменения, которые я отправляю в удаленный репозиторий, и не могу завершить их после разрешения конфликтов. Я попытался перебазировать следующим образом:

$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
Applying: My Commit Message
Using index info to reconstruct a base tree...
M   dir_a/dir_b/dir_c/myfile.py
.git/rebase-apply/patch:51: trailing whitespace.

.git/rebase-apply/patch:56: trailing whitespace.

.git/rebase-apply/patch:128: trailing whitespace.

.git/rebase-apply/patch:141: trailing whitespace.

.git/rebase-apply/patch:145: trailing whitespace.

warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging dir_a/dir_b/dir_c/myfile.py
CONFLICT (content): Merge conflict in dir_a/dir_b/dir_c/myfile.py
error: Failed to merge in the changes.
Patch failed at 0001 My Commit Message
The copy of the patch that failed is found in: .git/rebase-apply/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 add dir_a/dir_b/dir_c/myfile.py
$ git commit dir_a/dir_b/dir_c/myfile.py -m"Fixed rebase conflicts"
[detached HEAD a5a4f3b3e] Fixed rebase conflicts
 1 file changed, 193 insertions(+), 13 deletions(-)

Но когда я пытаюсь продолжить, это не удается

$ git rebase --continue
Applying: My Commit Message
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 rebase --abort
$ git status
On branch rebase1
nothing to commit, working tree clean

Теперь я вижу (или верю, что я делаю) тот же результат, когда я начинаю перебазировать

$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
Applying: My Commit Message
Using index info to reconstruct a base tree...
M   dir_a/dir_b/dir_c/myfile.py

Falling back to patching base and 3-way merge...
Auto-merging dir_a/dir_b/dir_c/myfile.py
CONFLICT (content): Merge conflict in dir_a/dir_b/dir_c/myfile.py

error: Failed to merge in the changes.
Patch failed at 0001 My Commit Message
The copy of the patch that failed is found in: .git/rebase-apply/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".

после устранения конфликта я add а также rebase с тем же результатом:

$ git add dir_a/dir_b/dir_c/myfile.py
$ git rebase --continue
Applying: My Commit Message
Applying: My Commit Message For New Code I want to Rebase
Using index info to reconstruct a base tree...
M   dir_a/dir_b/dir_c/myfile.py
Falling back to patching base and 3-way merge...
Auto-merging dir_a/dir_b/dir_c/myfile.py
CONFLICT (content): My Commit Message
error: Failed to merge in the changes.
Patch failed at 0002 Made changes to pass flake8
The copy of the patch that failed is found in: .git/rebase-apply/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".

Что мне нужно делать / не делать, чтобы успешно отменить мои изменения?

3 ответа

Решение

Вы не должны фиксировать свои изменения при разрешении конфликтов перебазирования. После того, как вы закончили редактирование файлов для разрешения конфликтов, добавьте ваши новые изменения (например, git add dir_a/dir_b/dir_c/myfile.py) и закончите ребаз, используя git rebase --continue,

Я включил этот ответ, потому что он решил мою проблему, хотя и не совсем ту, о которой я говорил. Когда я впервые попытался rebase я сделал add мои измененные файлы без committing им, но без (я верил) никакой удачи, когда я пытался git rebase --continue, Затем я попытался commit мои изменения перед выполнением git rebase --continue, но все еще безуспешно.

Моя ошибка заключалась в том, что я не осознавал этого после устранения одного набора конфликтов, когда я снова пытался rebaseмогут возникнуть новые конфликты, которые необходимо будет устранить. Когда я исправил эти новые конфликты, я смог успешно rebase

Другие вопросы по тегам