Основные изменения исчезли. И без видимой причины.
Во-первых, я создал собственную ветку my_branch form feature_branch.
Я внес некоторые изменения и зафиксировал их локально.
Позже мне нужно было внести некоторые изменения, сделанные другими в feature_branch. Я сделал это с rebase.
Затем я принудительно отправил my_branch на сервер.
Пока все хорошо.
Затем я сделал больше изменений, зафиксировал их, вытащил feature_branch с сервера, сделал ребазинг (второй раз), и мои изменения пропали. У меня есть журналы rebase и журналы истории. Это то, что я только что сделал
Do some work.
$ git status
-> on my_branch with some changes.
$ git add . // add new files and updated files.
$ git commit -m "message"
$ git status
-> on my_branch, nothing to commit
$ git push --force // send my changes to my_branch on the server.
$ git checkout feature_branch
$ git pull // get latest changes from the server.
$ git checkout my_branch
$ git rebase feature_branch // this should merge my changes, not overwrite them!
-> bunch of merge messages and one conflict.
-> I fixed the one conflict.
Теперь, по крайней мере, некоторые из моих основных изменений прошли. Команда rebase ($ git rebase feature_branch "перезаписала мои измененные (и зафиксированные) файлы файлами из оригинала без видимой причины. Мы говорим о нескольких сотнях строк кода. Я еще не сделал $ git rebase - продолжайте, поскольку я заметил, что это потеряло мою работу.
Если я посмотрю в bitbucket на my_branch, который я нажал прямо перед выполнением команды rebase, я увижу свои изменения, которые я нажал. Но они отсутствуют локально после команды rebase.
Что могло пойти не так?
ПРИМЕЧАНИЕ: никто, кроме меня, не изменил my_branch.
Полагаю, у меня сейчас есть три варианта.
1) wipe my local git database, and try to restore from time machine.
2) try git merge --abort and hope.
3) try to get my_branch from the server again. I don't know how to do this, other than to delete my local git directory, and clone from scratch, then checkout the branch.
Есть предложения?
Вот журнал оскорбления:
git rebase feature_branch
First, rewinding head to replay your work on top of it...
Applying: <some old commit message1>
Using index info to reconstruct a base tree...
M somefile1
M somefile2
M somefile3
.git/rebase-apply/patch:160: trailing whitespace.
"xxx-keyspace-configs": [
.git/rebase-apply/patch:485: trailing whitespace.
.git/rebase-apply/patch:1258: new blank line at EOF.
+
.git/rebase-apply/patch:1299: new blank line at EOF.
+
.git/rebase-apply/patch:1341: new blank line at EOF.
+
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging somefile1
Auto-merging somefile2
Auto-merging somefile3
Auto-merging somefile4
Applying: <some old commit message2>
Using index info to reconstruct a base tree...
M somefile1
M simefile2
M somefile3
M somefile4
Falling back to patching base and 3-way merge...
Auto-merging somefile4
CONFLICT (content): Merge conflict in somefile4
Auto-merging somefile3
Auto-merging somefile2
Auto-merging somefile1
error: Failed to merge in the changes.
Patch failed at 0002 xxx
The copy of the patch that failed is found in: .git/rebase-apply/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".
Если я вернусь в состояние до перезагрузки и сделаю это снова, я снова потеряю свои изменения.
=== update ===
$ git reflog engage-swh
c051e4f4b (origin/my_branch, my_branch) my_branch@{0}: commit: <my last commit message>
b9275d1ae my_branch@{1}: commit: <my second from last commit message>
30a24608b my_branch@{2}: rebase finished: refs/heads/my_branch onto 732a052fd4e0a6c171b52acb84ddaf16d27956c1
11c60cd90 my_branch@{3}: commit: <my first commit message>
1b811e4b2 (feature-2019R07) my_branch@{4}: branch: Created from feature-2019R07
Если я посмотрю, скажем, file6 в bitbucket для ветви my_branch, то посмотри, что у меня есть локально, сразу после rebase, все добавленные мной строки пропали. Локальная версия совпадает с версией до внесения изменений. Все мои изменения на пульте. Файл, который был «перезаписан», не является файлом, который был объединен (т.е. не в выводе выше)
Я только что попытался сделать
$ git merge --abort
Я пытаюсь вернуть утраченную работу.
В результате:
fatal: There is no merge to abort (MERGE_HEAD missing).
Полагаю, у меня остается два варианта: восстановить резервную копию с машины времени или удалить директорию моего проекта, снова клонировать проект и оформить заказ my_branch. Вопрос в том, как мне перебазировать feature_branch без того, чтобы он снова перезаписывал мои изменения? Я предполагаю, что не могу слиться, так как изначально я сделал ребаз.
==== обновление 2 ====
Я только что попробовал:
$ git log --oneline --graph --decorate
По предложению падавина
Он показывает очень длинный список коммитов всех людей, которые работают над веткой feature_branch, вместе со всеми их ветками вне этого. Там нет ошибок или что-то, что дает подсказку. Вот первые несколько строк:
* a84d5dcbd (HEAD) my first commit message.
* 139d71db8 (origin/feature_branch, feature_branch) made xxx in_active
* bedea7520 Merge branch 'feature_branch' of https://bitbucket.org/xxx/xxx-parent into feature_branch
|\
| * b4c06d0c8 Merge branch 'feature_branch' of https://bitbucket.org/xxx/xxx-parent into feature_branch
| |\
| * | 7996ca962 Release Prep
* | | 76aaddfcf system config update
| |/
|/|
=== update ====
Я устал заканчивать ребазинг, хотя моя работа была "перезаписана".
Я исправил один файл, который находился в конфликте, сделал «$ git add». чтобы пометить его как исправленный, затем сделал «$ git rebase --continue».
Теперь я получаю еще кучу ошибок:
$ git rebase --continue
Applying: <one of my commit messages>
Applying: refactored merger, added update
Using index info to reconstruct a base tree...
M somefile1
M somefile2
M somefile3
Falling back to patching base and 3-way merge...
Auto-merging somefile3
Auto-merging somefile2
Auto-merging somefile1
CONFLICT (content): Merge conflict in somefile1
error: Failed to merge in the changes.
Patch failed at 0003 refactored merger, added update
The copy of the patch that failed is found in: .git/rebase-apply/patch