git push提交代码出现“One or more refs/for/ names blocks change upload”问题的解决办法

来源:互联网 发布:linux虚拟机加载u盘 编辑:程序博客网 时间:2024/05/29 02:30
在公司内网建了一个Android的源码库,使用repo脚本进行控制。某一天(就是昨天)在./framework/base/ git库下提交代码突然有问题,但是在其他库下提交没有问题,push命令为:git push aosp HEAD:refs/for/branch_name
错误:fatal: One or more refs/for/ names blocks change upload
           fatal: Could not read from remote repository.

对于我这个开发狗临时兼任一下SCM角色的人来说,必须先度娘/google了。网上的方法有:

To solve this problem all real branches that exist under the refs/for/ namespace have to be deleted or renamed in the remote git repository.

To see which branches exist under the refs/for/ namespace a Gerrit administrator can run the following command:
$ git for-each-ref refs/for
If all these branches should be deleted it can be done with the following command:
$ for n in $(git for-each-ref --format='%(refname)' refs/for); do git update-ref -d $n; done
Branches under the refs/for/ namespace can be created by users that bypass Gerrit and push directly to the git repository itself (not using the Gerrit server’s SSH port).

但是本地使用git for-each-ref refs/for并没有返回任何东西;因此这个解决办法对我遇到的问题没有用。

度娘搜索不到什么有用的信息,只能FQ用google了,发现有一篇文章和我的问题很像:http://repo-discuss.narkive.com/UDj3xce9/refs-for-names-blocks-but-no-actual-refs-for-branch-there

然后根据文中所讨论提到的命令:
git ls-remote aosp refs/for/*
返回结果为:
$ git ls-remote aosp refs/for/*
7de2464cf0c651c51bbc6cdc7ac4c531bd4c9f0a refs/for/imdata_l_r8
$ git show 7de2464cf0c651c51bbc6cdc7ac4c531bd4c9f0a
fatal: bad object 7de2464cf0c651c51bbc6cdc7ac4c531bd4c9f0a

应该是由于这个object有问题导致的,但该文章最后只是说要删掉这个ref,但是没有说具体怎么操作。然后又是各种搜索,无功而返。最后实在没有办法,跑到服务器的代码库中,对比了一下./platform/frameworks/base.git/refs/ 和 ./platform/frameworks/av.git/refs/,发现base.git里面比av.git多一个for文件夹,并且该文件夹里面有一个imdata_l_r8的文件,里面就存着7de2464cf0c651c51bbc6cdc7ac4c531bd4c9f0a字符串,应该代表了7de2464cf0c651c51bbc6cdc7ac4c531bd4c9f0a object。一狠心把for文件夹全部删除,OK,再在本地使用git ls-remote aosp refs/for/* 已经查不到任何东西了。然后使用git命令提交,搞定,gerrit起作用了。


真不容易,搞了一天,mark一下!

0 0