主要更改已消失。而且没有明显的原因。
首先,我以feature_branch形式创建了自己的分支my_branch。
我做了一些更改,并将其提交到本地。
稍后,我需要提取其他人在feature_branch上所做的一些更改。我是通过变基做到这一点的。
然后我用力将my_branch推到服务器上。
到目前为止很好。
然后,我做了更多更改,提交了它们,从服务器中拉出feature_branch,重新设置了基础(第二次),我的更改消失了。我有基准日志和历史日志。这就是我刚刚做的事
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 --continue,因为我注意到它失去了我的工作。
如果我在执行rebase命令之前就在my_branch的bitbucket中进行了查看,那么我会看到自己推送的更改。但是自从执行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".
如果我恢复到重新设置基准之前的状态,然后再次执行此操作,我将再次丢失所做的更改。
===更新===
$ 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
如果我在分支my_branch的bitbucket中查看file6,然后在重新设置基准后直接查看本地的内容,则添加的所有行均消失了。本地版本与我进行更改之前的版本相同。我所有的更改都在遥控器上。已被“覆盖”的文件不是已合并的文件(即不在上面的输出中)
我只是想做
$ git merge --abort
我试图找回丢失的工作。
结果是:
fatal: There is no merge to abort (MERGE_HEAD missing).
我想这给我留下了两个选择,从时光机恢复备份,或删除我的项目目录,再次克隆项目,并检出my_branch。问题是,如何重新设置feature_branch的基础,而又不覆盖所做的更改?我认为我无法合并,就像我最初调整基准一样。
====更新2 ====
我刚刚尝试过:
$ git log --oneline --graph --decorate
根据padawin的建议
它显示了在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
| |/
|/|
===更新====
即使我的工作已被“覆盖”,我还是疲于完成基准。 我修复了一个有冲突的文件,做了“ $ 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
答案 0 :(得分:1)
几件事:
git push --force
?由于您是唯一在分支机构工作的人,请查看分支机构的引用日志:
git reflog my_branch
运行一些日志以查找您丢失的提交
根据以下讨论,您发生了冲突,并且现在处于重新部署的中间。然后,您需要暂存要在git rebase
试图应用的提交中要应用的所有未暂存的更改,然后运行git rebase --continue
继续进行重新设置。
答案 1 :(得分:0)
好吧,经过很多痛苦,我想我知道问题出在哪里。重新使用几次后,Rebase分阶段工作。在这些阶段中,您会暂时“丢掉”您的工作,直到以后工作完成。我不知道这件事发生了-我以为一切都丢了。