git rebase HEAD ^^ не удается - PullRequest
       58

git rebase HEAD ^^ не удается

0 голосов
/ 24 сентября 2019

Меня это озадачивает: обычно git rebase HEAD^^^^^^^ просто утверждает, что:

Текущий тест ветки обновлен.

Сегодня, однако, я демонстрировал git rebase -i коллеге, и я сначала сделал git rebase 63c1e126, где 63c1e126 - это фиксация, выбранная из журнала фиксации, и перебазировка не удалась из-за конфликта.Как это может быть?

Причиной выполнения rebase -i было устранение проблемы, когда одни и те же коммиты применялись дважды после некоторой другой перебазировки / принудительного толчка (я полагаю), и на первом этапе возник конфликткоммит, который был применен во второй раз (с другим хэшем коммита и некоторыми изменениями пробелов).

Вывод из git:

$ git rebase 63c1e126
First, rewinding head to replay your work on top of it...
Applying: Cherrypicking python files to commit to master
Applying: (#1379) Included .nc files in ignore-list
Applying: Added monthly index-file and stations rtf to gitignore
Applying: Initial clean-up
Applying: Reformat using Eclipse formatting rules
Applying: (#1386) Remove panelGrid warning on login page
...
Applying: (#1378) Apply replacement column headers on export
Applying: (#1378) Eclipse formatting
Applying: (#1381) facilitating new object_spec
Applying: Initial clean-up
Using index info to reconstruct a base tree...
M   WebApp/WebContent/resources/python/export/py_func/copernicus.py
.git/rebase-apply/patch:33: trailing whitespace.
      #local_folder = filepath_local.rsplit('/',1)[0] 
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging WebApp/WebContent/resources/python/export/py_func/copernicus.py
CONFLICT (content): Merge conflict in WebApp/WebContent/resources/python/export/py_func/copernicus.py
error: Failed to merge in the changes.
Patch failed at 0022 Initial clean-up
Use 'git am --show-current-patch' to see the failed patch

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

git log выдает что-то вроде (Замененные хэши коммитов):

$ git log --graph --decorate --oneline
* aaaaaaaa (HEAD -> github/1381_bak, origin/github/1381_bak) (# 1381) index file added to gitignore
* aaaaaaaa (#1381) Clean up
* aaaaaaaa (#1381) Added delete folder functionality
* aaaaaaaa (#1381) Added export-date to CMEMS export database
* aaaaaaaa (#1381) Working CMEMS version
* aaaaaaaa (#1381) Making local_folder global variable, and minor bug-fixes
* aaaaaaaa (#1381) General cleanup
* aaaaaaaa (#1381)  Removing stray debugging
* aaaaaaaa (#1381) Removing bad use of try:except statements
* aaaaaaaa (#1381) General clean-up and improved SQL-functionality
* aaaaaaaa (#1381) Facilitating change in directory structure
*   aaaaaaaa Merge remote-tracking branch 'origin/github/1381' into github/1381
|\  
| * aaaaaaaa (#1381) facilitating new object_spec
| * aaaaaaaa (#1381) Improved handling of L0 files
| * aaaaaaaa (#1381) toml files included in setup-scripts
| *   aaaaaaaa Merge branch 'github/1381' into origin/github/1381
| |\  
| | * aaaaaaaa (#1381) Fixed bug in sql-db
| | * aaaaaaaa (#1381) Updated .gitignore file
| | * aaaaaaaa (#1381) Minor function renaming. just aesthetic.
| | * aaaaaaaa (#1381) get_export_list:  bug-fix
| | * aaaaaaaa (#1381) Putting cmems_delay function on hold.
| | * aaaaaaaa (#1381) Reworked logic to omit use of sys.exit()
| |/  
| * aaaaaaaa (#1381) Style and format cleanup for readability
| * aaaaaaaa (#1381) meta handling clean-up
| * aaaaaaaa Initial clean-up
* | aaaaaaaa (#1381) facilitating new object_spec
* | aaaaaaaa (#1381) Improved handling of L0 files
* | aaaaaaaa (#1381) toml files included in setup-scripts
* | aaaaaaaa (#1381) Fixed bug in sql-db
* | aaaaaaaa (#1381) Updated .gitignore file
* | aaaaaaaa (#1381) Minor function renaming. just aesthetic.
* | aaaaaaaa (#1381) get_export_list:  bug-fix
* | aaaaaaaa (#1381) Putting cmems_delay function on hold.
* | aaaaaaaa (#1381) Reworked logic to omit use of sys.exit()
* | aaaaaaaa (#1381) Style and format cleanup for readability
* | aaaaaaaa (#1381) meta handling clean-up
* | aaaaaaaa Initial clean-up
* | aaaaaaaa (origin/v2.0.6a) (#1378) Eclipse formatting
* | aaaaaaaa (#1378) Apply replacement column headers on export
* | aaaaaaaa (#1378) Don't include units if replacement column headers are configured
* | aaaaaaaa (#1378) Add replaceColumnHeaders to export config
* | aaaaaaaa (#1386) Remove panelGrid warning on login page
* | aaaaaaaa Reformat using Eclipse formatting rules
|/  
* aaaaaaaa (origin/master, origin/HEAD, master) Added monthly index-file and stations rtf to gitignore
* aaaaaaaa (#1379) Included .nc files in ignore-list
* aaaaaaaa Cherrypicking python files to commit to master
* 63c1e126 (#1331) integration with new cmems_converter.py

1 Ответ

2 голосов
/ 25 сентября 2019

git log лжет вам и показывает линейную историю.История Git не линейна, ветви и слияния буквально таковы.git log --graph показывает правдивую историю.В твоей истории есть слияния.Это означает, что ваша история коммитов выглядит примерно так.

63c1e126 - B - C - I - G - H - K [github/1381_bak]
            \         /
             D - E - F

git rebase по умолчанию отбрасывает коммиты слияния и сглаживает вашу историю.Примерно так.

63c1e126 - B - D1 - C1 - E1 - I1 - F1 - G1 - H1 - K1 [github/1381_bak]

Обратите внимание, что коммиты веток теперь чередуются.Это может вызвать конфликты, так как E не был написан поверх C.

Если мы посмотрим на порядок перебазирования, мы увидим чередующиеся коммиты сразу после Added monthly index-file and stations rtf to gitignoreInitial clean-up, и Reformat using Eclipse formatting rules изначально были написаны поверх Added monthly index-file and stations rtf to gitignore.Но перебазировка ставит Reformat using Eclipse formatting rules поверх Initial clean-up.Аналогичные проблемы со вторым Initial clean-up.

$ git rebase 63c1e126
First, rewinding head to replay your work on top of it...
Applying: Cherrypicking python files to commit to master
Applying: (#1379) Included .nc files in ignore-list
Applying: Added monthly index-file and stations rtf to gitignore
Applying: Initial clean-up                                        (right)
Applying: Reformat using Eclipse formatting rules                 (left)
Applying: (#1386) Remove panelGrid warning on login page          (left)
...
Applying: (#1378) Apply replacement column headers on export
Applying: (#1378) Eclipse formatting
Applying: (#1381) facilitating new object_spec
Applying: Initial clean-up

Обратите внимание, что если вы используете довольно новые git rebase -r или --rebase-merges, Git попытается сохранить ваши ветви и воссоздать слияния.Если вы явно не хотите сгладить свою историю, используйте -r.

...