git - 尝试恢复已删除的分支时出现“错误:没有这样的提交”?
问题描述
我已经在 Gerrit 中提交了一个文件(推送它),但我认为,不幸的是,我在本地删除了我提交的那个分支。如何解决?请帮忙。
我试过了
git branch --contains 31436fd7200566967f85bfb1ee5425f9b599b908
但它显示
error: no such commit 31436fd7200566967f85bfb1ee5425f9b599b908
编辑:是的,我已经在本地安装了 git,并且我在本地的分支上工作。
我从 Gerrit 网站获得了提交 ID,我已经提交了。
好的,两天前,当我尝试提交更改时出现问题,比如说 A。我尝试使用“./logerrit submit master”提交它,但我得到的只是:
Counting objects: 32, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (32/32), 100.46 KiB | 0 bytes/s, done.
Total 32 (delta 22), reused 0 (delta 0)
remote: Resolving deltas: 100% (22/22)
remote: Counting objects: 79789, done
remote: Processing changes: refs: 1, done
To ssh://logerrit/core
! [remote rejected] HEAD -> refs/for/master (change
https://gerrit.libreoffice.org/54112 closed)
error: failed to push some refs to 'ssh://logerrit/core'
因此,它说两次提交的更改 id 相同——我正在提交的补丁和我几天前已经提交并现在合并的补丁。我尝试做堆栈溢出或任何其他博客中提到的所有可能的事情-我尝试更改 id,以便在下一次“git commit --amend”时 git 自动更改 id,因为我没有用遇到同样的错误,我还尝试通过删除行 <<<<<<<<<<< ============ 和 >>>>>>>>>> 来解决冲突> 但我说得对吗?这是解决它的正确方法吗?然后我尝试“git rebase master”,然后我收到错误消息:
First, rewinding head to replay your work on top of it...
Applying: smartart : test documents
Using index info to reconstruct a base tree...
M sd/qa/unit/import-tests-smartart.cxx
Falling back to patching base and 3-way merge...
Auto-merging sd/qa/unit/import-tests-smartart.cxx
CONFLICT (content): Merge conflict in sd/qa/unit/import-tests-
smartart.cxx
error: Failed to merge in the changes.
Patch failed at 0001 smartart : test documents
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".
我尝试更改分支,然后尝试再次使用 master 重新调整更改,因为它已经是最新的,但它没有用。然后,我删除了“本地”创建的额外分支,并且错误地,我可能删除了我已提交给 Gerrit 的分支之一。
现在我的问题是:
- 我可以在本地系统中再次恢复已删除的分支吗?可能吗?
- 如何解决合并问题或您在变基后看到的错误。我有一个强烈的怀疑,我可能做错了什么。请帮助,如果我没有涵盖任何内容,请告诉我。
第一个和第二个问题都与不同的文件/分支有关,但可能彼此相关。
解决方案
忘记提交 31436fd7200566967f85bfb1ee5425f9b599b908。如果你真的在 Gerrit 中合并了你的提交,它就在远程分支上。要从远程分支创建和签出本地分支,请执行:
git checkout -b local-branch remotebranch
前任:
git checkout -b my-feature origin/release1.0
推荐阅读
- workflow - 如何在 AEM 中等待大坝更新资产工作流程完成
- c++ - 静态方法/变量的内存布局
- sql-server - Azure 数据工厂无法执行复制数据任务到 SQL Server
- css - CSS网格 - 从每个开始的自动高度开始所有的coumns
- javascript - 错误:无法注册层:ApplyLayer 退出状态 1 标准输出:标准错误:lchown /git-2.9.3/git-gui/version:无效参数
- javascript - Css悬停动画闪烁/循环
- javascript - 如何制作一个同时上升和下降的循环?
- apache - 如何启用 mod_xsendfile?
- sharepoint - 权限请求未显示在管理员中
- spring - 在 Spring Boot 中运行 mongo 工具