GitHub自动合并后出现致命错误

时间:2012-04-10 21:57:46

标签: git github git-fetch

我在位于here的GitHub上有一个存储库。我为某人创建了一个工作分支,他们分配了回购,在工作分支上做了一些更改并提交了拉取请求。

我尝试了更改,一切都很好,因为GitHub提供自动合并拉取请求,我继续点击绿色的“合并拉取请求”按钮。除了对工作分支的更改应用于我可以使用的主分支外,一切都很顺利。

现在的问题是我或其他任何人都无法获取存储库。我收到这个错误:

dp@dpub:/tmp/gh$ git clone git://github.com/dapphp/securimage.git
Initialized empty Git repository in /tmp/gh/securimage/.git/
remote: Counting objects: 333, done.
remote: Compressing objects: 100% (269/269), done.
remote: Total 333 (delta 91), reused 297 (delta 55)
Receiving objects: 100% (333/333), 3.91 MiB | 2.78 MiB/s, done.
Resolving deltas: 100% (91/91), done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with nonexistant object 31d684d383913c4cf1a0d5ff0691c2c163284a35
fatal: Cannot update the ref 'HEAD'.

这导致没有创建目录或下载任何工作文件。我已经搜遍了各种可能的方法来解决这个问题,但大多数人都在谈论向git repo发出命令,我无法做到这一点,因为我无法在第一时间获得repo的副本。

我发现我仍然可以使用以下内容克隆远程分支:git clone -b audiofixes git://github.com/dapphp/securimage.git但我仍然收到有关错误引用的错误,我无法找出可以运行以解决问题的任何命令。如有必要,我愿意撤消这些修改。

如果它有帮助,一旦我克隆了另一个分支,这里是git branch -a的输出:

* audiofixes
  remotes/origin/2.0.2
  remotes/origin/3.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/audiofixes
  remotes/origin/securimage_flash

此时我真的不知道我可以做些什么(如果有的话)来修复存储库的状态。

感谢您的任何建议。

编辑:根据请求输出一些命令。

$ ls .git/refs/remotes/origin
HEAD

$ ls .git/objects
info/  pack/
# info is empty, pack has pack-b8add06e9a6864ea44a58c06b8bd549eedd90c94.idx and pack-b8add06e9a6864ea44a58c06b8bd549eedd90c94.pack

$ cat .git/refs/remotes/origin/master
cat: .git/refs/remotes/origin/master: No such file or directory

$ cat .git/refs/remotes/origin/HEAD 
ref: refs/remotes/origin/master

1 个答案:

答案 0 :(得分:2)

NEW:

显然1)github不提供ssh访问:(,和2)不可能通过git协议在不同的机器之间共享reflog。

所以......你显然已经创建了一张票,但是你不一定需要它们来修复存储库。您只需要为他们(因为他们有特权访问权限)在服务器的repo上运行git reflog master然后粘贴结果供您查看。在该文件中,查找master的先前SHA-1值(因为当前的值似乎不起作用)。一旦你有了,你(我认为)可以做到以下(在你自己的计算机上):

$ git checkout -b temp
$ git update-ref refs/heads/temp $SHA1
$ git push -u origin +temp:master

这将撤消服务器上的合并操作。

您可以在不必从服务器获取reflog的情况下获得以前工作的SHA1。在您的本地仓库(或您朋友的本地仓库)中,之前工作的提交 存在于那里。如果你能找到一种在那里找到它的方法,那么你可以继续上面的建议。

老人:这是我的第一个想法。如果您能够从服务器复制.git/logs目录,那么它将存储master分支的所有先前值。具体来说,文件.git/logs/refs/heads/master将是具有该分支的先前值的原始文本文件。例如(我不知道github是否允许你这样做):

$ git clone https://github.com/dapphp/securimage.git -b audiofixes
$ scp github.com:/dapphp/securimage.git/logs/refs/heads/master .git/logs/refs/remotes/origin/master
$ git update-ref refs/remotes/origin/master refs/remotes/origin/master@{1} #see "Date Spec" section of http://book.git-scm.com/4_git_treeishes.html

理论上将值更改为以前的master。但是它只会在本地执行,并且实际上不会更改服务器上的值,这是我们真正需要的。因此,如果您可以直接ssh到服务器并在那里运行最后一个命令,那么(理论上)将通过简单地撤消合并来解决问题。

这就是我能想到的最重要的事情。但我真的很喜欢像这样解决git难题,所以我会让它在我的头脑中停留一段时间:)