2011-12-21 85 views
8

我跑到下面的命令,因为我想将我的分公司生产回,而无需先签:refname是模糊的,拉失败

git branch -f production HEAD~1 

现在我得到以下警告,当我结帐生产:

warning: refname 'production' is ambiguous. 

我然后运行:

git pull 

我收到以下错误:

First, rewinding head to replay your work on top of it... 
Fast-forwarded production to 7463e01c536ad52746b8879ef3d70ffd5a8db31e. 
error: Ref refs/heads/production is at 252038dfa22caba8a816a68dcb005c625e44c51f but expected ae5b621609c1b5b430e3d30711157298f842942a 
fatal: Cannot lock the ref 'refs/heads/production' 
Could not move back to refs/heads/production 

虽然我可以拉其他分支。我怎样才能解决这个问题?

更多信息

git tag不返回任何输出。我以前有一个生产资源库,但现在我已重新命名,住

> ~/repo (chris-membership-fees)$ git show-ref | grep production 
88e0c37c9ae4ff6967ddd027b62b62fa2c0ac272 refs/heads/production 
9d739cff44a898f0c68da33fb22a230985e479ce refs/remotes/backup/production 

~/repo (chris-membership-fees)$ git branch -a | grep production 
    production 
    remotes/backup/production 

登录

我所标记的第一次修订的,第二个作为B(注意,版本号已经改变因为现在生产不同)。这是日志,通过装饰

* commit 7463e01c536ad52746b8879ef3d70ffd5a8db31e (**tag: a**, backup/live-master, production, live-master) 
| 
| Date: Wed Dec 28 11:47:49 2011 +1100 
| 
|  Merge remote-tracking branch 'origin/joseph-quick-fix' 
| 
* commit f35f0259c4e36d46dd1df71b3293bef6105cef98 (origin/hotfix-googleplusdirectconnect) 
| 
| Date: Fri Dec 23 12:25:27 2011 +1100 
| 
|  Add google plus link tag to home page for direct connect 
|  
* commit 8b3a30ef2909439ac18b65ebbb316eb0cdd2d61c 
|\ Merge: f696f3e 88e0c37 
| | 
| | Date: Wed Dec 21 14:28:45 2011 +1100 
| | 
| |  Merge branch 'master' into chris-hotfix 
| | 
* | commit f696f3e2b8f4a19ec2b2c2a3638c68e7a52836e3 (origin/chris-hotfix, backup/chris-hotfix, chris-hotfix) 
| | 
| | Date: Wed Dec 21 11:56:10 2011 +1100 
| | 
| |  Fixed buyer price info 
| |  
| * commit 88e0c37c9ae4ff6967ddd027b62b62fa2c0ac272 
| |\ Merge: c9655da ae5b621 
| |/ 
|/| Date: Wed Dec 21 11:53:36 2011 +1100 
| | 
| |  Merge branch 'master' of git.freelancer.com:production into production 
| | 
* | commit ae5b621609c1b5b430e3d30711157298f842942a (HEAD, **tag: b**) 
| | 
| | Date: Wed Dec 21 10:51:47 2011 +1100 
| | 
| |  Merge branch 'master' of git.freelancer.com:production 
| | 
| * commit c9655da9c1627ab53720ae818affdd1e6f14119f (origin/game-shadow2) 
| | 
| | Date: Tue Dec 20 18:41:57 2011 -0500 
| | 
| |  * Removed debugging code 
| |  
| * commit ca88d33538bd3b99ea7c186b5b531e611847989d 
| |\ Merge: 99e983a c397a8b 
| |/ 
|/| Date: Tue Dec 20 17:25:24 2011 -0500 
| | 
| |  Merge remote-tracking branch 'production/master' into shadow2 
+0

'git branch -a'的输出是什么? – 2011-12-21 01:30:48

+2

你也可以使用'git show-ref'来显示所有未缩写的ref。 – 2011-12-21 01:36:09

+0

您使用的是哪个版本的git? – 2011-12-21 08:17:40

回答

6

感谢Johannes Sixt在Git mailing list上。

The most likely reason is that you have a ref 'production' directly in the .git directory. Perhaps you or one of your scripts created it accidentally using 'git update-ref production ae5b621', i.e., without giving the full ref path name

它实际上并不在.git根目录中,但我在分支中有一个空的生产文件夹。

+0

我意外地使用git-update-ref创建了一个名为'master'的文件,这导致了同样的问题。简单的修复方法是删除.git/master文件。感谢提示。 – meowsqueak 2013-02-12 04:10:18

6

简化如果你只是想删除警告:

git config --global core.warnambiguousrefs false 

警告来了,因为你有一个分支命名的产量,并且远程命名的生产。将两者中的任何一个重命名为其他内容将是理想的。

+0

我认为这不太合理,但 - 当我阅读[git rev-parse](http://schacon.github.com/git/git-rev-parse.html #_specifying_revisions)文档,只有'refs/remotes/production/HEAD'存在时,'production'远程才会产生歧义,而'git show-ref'输出中没有显示。 – 2011-12-21 09:45:09

+0

@马克:你说得对。我改名为生产,但我仍然看到含糊不清的警告 – Casebash 2011-12-22 23:53:07

+0

@Casebash - 让我试着重现并更新答案 – manojlds 2011-12-23 00:02:18

6
> ~/repo (chris-membership-fees)$ git show-ref | grep production 
88e0c37c9ae4ff6967ddd027b62b62fa2c0ac272 refs/heads/production 
9d739cff44a898f0c68da33fb22a230985e479ce refs/remotes/backup/production 
88e0c37c9ae4ff6967ddd027b62b62fa2c0ac272 refs/remotes/production/master 

refs/heads/production是ambiguos由于refs/remotes/production。分辨率是通用的,与参考类型前缀无关,因此分支,标签,遥控器甚至自定义参考名称不得相互冲突。

+1

我把生产改名为生活,所以现在只有前两个结果出现,但我仍然看到冲突 – Casebash 2012-01-02 23:06:10

+0

你的意思是'错误:Ref refs/heads/live在252038dfa22caba8a816a68dcb005c625e44c51f但是预期是ae5b621609c1b5b430e3d30711157298f842942al',或'warning:refname'生活'是不明确的。“? – 2012-01-03 00:01:29

+0

我仍然有两个问题。一次结帐时,另一次当我拉。我现在使用livemaster作为我的本地分支而没有问题,但我仍然好奇 – Casebash 2012-01-03 01:44:15