git reset --hard 错误:无法解析对象

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25900655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:29:17  来源:igfitidea点击:

git reset --hard error: Could not parse object

gitterminalosx-mavericks

提问by learner

This is not the first time I am doing a hard reset on my repo but this time, I am getting an error. I am working on an iOS Project. I am doing the reset from terminal. How do I fix the fatal error

这不是我第一次对我的 repo 进行硬重置,但这一次,我遇到了错误。我正在开发一个 iOS 项目。我正在从终端进行重置。如何修复致命错误

fatal: Could not parse object 'e88056ac5d58fb0bbd23d3fe929eac01712d964'

回答by Jiggs

I have same problem and fixed.

我有同样的问题并已修复。

This problem occurs when there have been changes like force-pushes to a git repo which is referenced in a Gemfile.

The solution is is to comment that gem line in Gemfile, run bundle, uncomment it and bundle again. Then the Gemfile.lock will reference a valid git revision.

当对 Gemfile 中引用的 git 存储库进行强制推送等更改时,会出现此问题。

解决方案是在 Gemfile 中注释该 gem 行,运行 bundle,取消注释并再次捆绑。然后 Gemfile.lock 将引用有效的 git 修订版。

Found in this link https://semaphoreci.com/docs/fail-could-not-parse-object.html

在此链接中找到https://semaphoreci.com/docs/fail-could-not-parse-object.html

回答by Justin

For me, the problem was that on my local machine I needed to pull the latest version of my branch, merge, and commit. Then the git reset --hard {hash}worked on the server I was running the command on.

对我来说,问题是在我的本地机器上,我需要拉取最新版本的分支、合并和提交。然后在git reset --hard {hash}我运行命令的服务器上工作。

回答by MambaHJ

May be you should push your code to remote directory first and then execute the command,

可能是您应该先将代码推送到远程目录,然后再执行命令,

git reset --hard <commit_id>

Finally the bug will be fixed.

最终将修复该错误。

回答by francojay

Try updating your local repo with

尝试更新您的本地存储库

git fetch

回答by Faka

If you have a git shallow clone (clone with command: git clone --depth=1 [email protected]:foo/bar.git), this might be the problem.

如果您有一个 git 浅克隆(使用命令克隆:)git clone --depth=1 [email protected]:foo/bar.git,这可能是问题所在。

Try this out:

试试这个:

git fetch --unshallow

and then git resetmay be working.

然后git reset可能正在工作。

Ref:

参考:

回答by Johanna Bulla

First update external branch git remote update Then git reset --hard

先更新外部分支 git remote update 然后 git reset --hard