Git 推送到 github 失败:无法读取对象

发布于 2024-12-06 02:00:03 字数 985 浏览 1 评论 0原文

故事:

我一直在我的台式机和笔记本电脑上开发 RoR 应用程序。提交对另一个人所做的更改、将它们推送到 github 并获取和下载是非常方便的。合并到其他上。

起点是这样的:我在桌面上提交了最新的更改,将它们推送到 github,然后获取并将它们合并到我的笔记本电脑中。然后,我在笔记本电脑上做了一些提交并推送到了 github。进行更改,合并到我的桌面(使用 --no-ff)。然后,发生了所有恶作剧的可能根源:我恢复了桌面以提交最新的获取和更新之前的位置。合并。用它做了一些开发工作,提交,推送到 github。在笔记本电脑中,我也进行了恢复,不过我将其恢复到了一次提交,该提交是在最近从 github 获取、再次获取并合并这些内容之间进行的。恢复台式机和笔记本电脑后出现了一些错误消息,但一切仍然运行良好,我继续在两台机器上工作。

到目前为止。我尝试从我的笔记本电脑推送到 github,它给出了以下输出:

 Counting objects: 106, done.
 error: unable to find 5a2a4ac...
 error: unable to find bc36923...
 error: unable to find ecb0d86... 
 error: unable to find f76d194...
 error: unable to find f899df7...
 Compressing objects: 100% (64/64), done.
 fatal: failed to read object 5a2a4ac... : Invalid argument
 error: failed to push some refs to 'git@github:username/repo.git'

那么问题是,这里到底发生了什么?

编辑:似乎由于暂停我的笔记本电脑并将其从一个地方移动到另一个地方,在该状态下以某种方式搞砸了硬盘驱动器。 fsck 输出不可用,因为我们解决了问题并继续工作,但 IIRC 一些分支和提交悬而未决,包括 git 无法读取的提交。 - 提姆

The story:

I've been developing a RoR-app in both my desktop and laptop. It was quite handy to commit changes made on another, push them to github and fetch & merge on other.

The starting point is this: I committed latest changes on my desktop, pushed them to github and then fetched and merged them into my laptop. Then, I made some commits on laptop and pushed to github. Took the changes, merged to my desktop (with --no-ff). THEN, happened the probable source of all mischiefs: I reverted the desktop to commit where it was before the latest fetch & merge. Made some development work with it, committed, pushed to github. In the laptop, I did the revert as well, though I reverted it to a commit which was made somewhere between the latest fetch from github, fetched again and merged those. Some error messages came after reverting desktop and laptop both, but things worked still fairly well and I kept working on both machines.

Until now. I tried to push from my laptop to github, which gives the following output:

 Counting objects: 106, done.
 error: unable to find 5a2a4ac...
 error: unable to find bc36923...
 error: unable to find ecb0d86... 
 error: unable to find f76d194...
 error: unable to find f899df7...
 Compressing objects: 100% (64/64), done.
 fatal: failed to read object 5a2a4ac... : Invalid argument
 error: failed to push some refs to 'git@github:username/repo.git'

So, the question is, what exactly took place here?

EDIT: It seems that because of suspending my laptop and moving it from place to place in that state screwed up the hard drive somehow. The fsck output is unavailable because we worked around the problem and kept on working, but IIRC some branches and commits were dangling, including that commit which git failed to read. - Teemu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

椒妓 2024-12-13 02:00:03

我遇到过这类问题。

我的“解决方案”通常是获取我想要的代码,将其复制到新目录中,删除 .git 文件,然后为其创建一个新的 github,然后连接两个,而不是花费数小时尝试解决和修复这些问题照常。

尽管这可能不是对您提出的细节的具体答案,但我发现 git/github 问题可能有多种发生方式,而不是希望我现在成为“git 专家”(它正在发生,但需要时间),我执行上述操作并继续我的实际应用程序开发。

I have run into these kinds of issues.

Rather than spending hours trying to resolve and fix these issues, my 'solution' is usually to take the code I want, copy it into a new directory, delete the .git files and then create a new github for it and then connect the two as usual.

Although this may not be a specific answer to the details you raise, I find that there can be a number of ways that git/github issues can happen and rather than wishing I was a 'git expert' now (it's happening but it takes time), I do the above and continue with my actual application development.

醉生梦死 2024-12-13 02:00:03

您遇到的问题是您正在尝试读取不属于“树”的对象。他们存在,但他们已成为孤儿。但是,git 允许您将一个项目合并到另一个项目,因此这是一种无需重新开始即可保留提交的方法,如下所示:

  1. git remote add -f somename git://somegitplace.com/user/some .git

  2. git merge -s ours --no-commit somename/master

  3. git read-tree --prefix=ext/somename -u somename/master

  4. git commit -m '外部合并'

  5. git pull -s subtree somename master

希望有所帮助。如果没有请告诉我,我们可以再次攻击它

The problem you have is that you are trying to read objects that are not part of your 'tree'. They exist but they have been orphaned. However, git allows you to merge one project to another so this is one way you can keep your commits without starting again, something like the following:

  1. git remote add -f somename git://somegitplace.com/user/some.git

  2. git merge -s ours --no-commit somename/master

  3. git read-tree --prefix=ext/somename -u somename/master

  4. git commit -m 'external merge'

  5. git pull -s subtree somename master

Hope that helps. Let me know if not and we can attack it again

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文