17

故事:

我一直在我的台式机和笔记本电脑上开发一个 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 未能读取的那个提交。- 提姆

4

2 回答 2

5

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.

于 2011-11-01T12:31:32.837 回答
1

您遇到的问题是您正在尝试读取不属于“树”的对象。他们存在,但他们已经成为孤儿。但是,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

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

于 2011-11-08T12:57:29.887 回答