GitHub自动合并后的致命错误 [英] Fatal error after GitHub automatic merge

查看:499
本文介绍了GitHub自动合并后的致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GitHub上有一个仓库,位于此处。我为某人创建了一个工作分支,他们分叉了回购协议,对工作分支进行了一些更改并提交了一个请求。



我尝试了更改,一切都很好,因为GitHub提供了自动合并拉取请求,我继续点击大的绿色合并拉取请求按钮。除了将工作分支的更改应用到我可以接受的主分支之外,一切都很好。



现在的问题是,存储库不能被我或任何其他人。我得到这个错误:

  dp @ dpub:/ tmp / gh $ git clone git://github.com/dapphp/ securimage.git 
在/tmp/gh/securimage/.git/
remote中初始化空的Git仓库:计数对象:333,完成。
remote:压缩对象:100%(269/269),完成。
remote:总数333(delta 91),重用297(delta 55)
接收对象:100%(333/333),3.91 MiB | 2.78 MiB / s,完成。
解决三角洲问题:完成100%(91/91)。
错误:refs / remotes / origin / master没有指向有效的对象!
错误:尝试使用不敏感对象编写ref refs / heads / master 31d684d383913c4cf1a0d5ff0691c2c163284a35
致命:无法更新ref'HEAD'。

这会导致没有创建目录或任何正在下载的工作文件。我已经搜索了所有可能的方法来解决这个问题,但大多数人都在讨论向git repo发布命令,这是我无法做到的,因为我无法获得首要副本。



我发现我仍然可以使用类似下面的方法克隆远程分支: git clone -b audiofixes git://github.com/dapphp/securimage.git 但我仍然得到一个关于错误ref的错误,我找不到任何我可以运行的命令来解决这个问题。如果有必要,我愿意撤消这些更改。



如果有帮助,一旦我克隆了不同的分支,这里是 git的输出分支-a

  * audiofixes 
遥控器/ origin / 2.0.2
remotes / origin / 3.0
remotes / origin / HEAD - >原产地/主产地
遥控器/原产地/ audiofixes
遥控器/原产地/ securimage_flash

在这一点上,我真的不知道我能做些什么来修复存储库的状态。



感谢您的任何建议。



编辑:按要求输出一些命令。

  $ ls .git / refs / remotes /产地
HEAD

$ ls .git / objects
info / pack /
#info为空,包有包 - b8add06e9a6864ea44a58c06b8bd549eedd90c94.idx和pack-b8add06e9a6864ea44a58c06b8bd549eedd90c94.pack

$ cat .git / refs / remotes / origin / master
cat:.git / refs / remotes / origin / master:没有这样的文件或目录

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


解决方案

新:



显然1)github不给ssh访问:(和2)不可能共享通过git在不同的机器之间重新引用日志协议。

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

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

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



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



老:这是我的第一个想法。如果您能够从服务器复制 .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}#请参阅http://book.git-scm.com/4_git_treeishes.html $ b的日期规格部分$ b

理论上应该 将数值更改为以前的主数据。但是,它只能在本地执行,并不会真正改变服务器上的值,这正是我们真正需要的。因此,如果你可以直接SSH到服务器,并在那里运行最后一个命令,那么(理论上)可以通过撤消合并来解决问题。





这就是我能想到的全部。但我真的很喜欢解决这样的Git谜题,所以我会让它在我脑海中停留一段时间:)


I have a repository on GitHub located here. I created a working branch for someone and they forked the repo, made some changes on the working branch and submitted a pull request.

I tried the changes and everything was good and since GitHub was offering to automatically merge the pull request, I went ahead and click the big, green "Merge Pull Request" button. All was well there except that the changes to the working branch were applied to the master branch which I can live with.

The problem is now that the repository cannot be fetched by me or anyone else. I get this error:

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'.

This results in no directory being created or any working files getting downloaded. I've searched all over for possible ways to resolve this but most talk about issuing commands to the git repo which I cannot do because I can't get a copy of the repo in the first place.

I've found I can still clone a remote branch using something like this: git clone -b audiofixes git://github.com/dapphp/securimage.git but I still get an error about the bad ref and I can't figure out any commands I can run to fix the problem. I'm willing to undo the changes if necessary.

In case it helps, once I clone a different branch, here is the output of 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

At this point I really have no idea what (if anything) I can do to fix the state of the repository.

Thanks for any suggestions.

EDIT: Some command output as requested.

$ 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

解决方案

NEW:

Apparently 1) github does not give ssh access :(, and 2) it's impossible to share reflogs between different machines through git protocol.

So... You already created a ticket apparently, but you don't necessarily need them to fix the repository. All you need is for them (since they have privileged access) to run git reflog master on the server's repo and then paste the results for you to view. In that file, look for the previous SHA-1 value of master (since the current one doesn't seem to work). Once you have that, you (I think) can do the following (on your own computer):

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

This will undo the merge operation on the server.

You may be able to get the previously working SHA1 without having to get the reflog from the server. In your local repo (or your friend's local repo), the previously working commit does exist somewhere in there. If you can figure out a way to find it there, then you can proceed with the above suggestion.

OLD: Here is my first thought. If you are able to copy the .git/logs directory from the server, then that will have stored in it all the previous values of the master branch. Specifically, the file .git/logs/refs/heads/master will be a raw text file with the previous values of that branch. For example (I don't know if github allows you to do this or not):

$ 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

that should theoretically change the value to what master was previously. However it will only do that locally and will not actually change the value on the server, which is what we really need. So if you could ssh directly to the server and just run that last command there, that would (again, theoretically) fix the problem for good by simply undoing the merge.

.

This is all that I can think of on top of my head. But I really like solving git puzzles like this, so I'll let it sit in my head for a bit longer :)

这篇关于GitHub自动合并后的致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆