Опитах се да ребаза някои промени, които изпращам до отдалечено хранилище, и не мога да го завърша, след като разреша конфликтите.
$ 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".
след определянето на конфликта I 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".
Какво трябва да направя, а не да направя, за да успея да възстановя промените си?
Отговори:
2 за отговор № 1Не трябва да „обвързвате” промените си при разрешаването на конфликтите на ребазите. След като редактирате файловете, за да разрешите конфликтите, добавете новите си промени (напр. git add dir_a/dir_b/dir_c/myfile.py
) и да завърши използването на rebase git rebase --continue
.
0 за отговор № 2
Включвам този отговор, защото той решава проблема, който имах, макар и не съвсем този, който бях заявил. rebase
направих add
без променените ми файлове committing
тях, но без (аз вярвах) някакъв късмет, когато се опитах git rebase --continue
, След това се опитах commit
промените ми, преди да изпълня git rebase --continue
, но все още неуспешно.
Моята грешка беше в това, че не осъзнах това, след като определих един конфликт, когато отново се опитах rebase
могат да възникнат нови конфликти, които трябва да бъдат фиксирани. Когато фиксирах тези нови конфликти, успях успешно rebase