警告:使用 git-svn 时,refname 'xxx' 不明确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4644380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:55:28  来源:igfitidea点击:

warning: refname 'xxx' is ambiguous when using git-svn

gitbranchgit-svnambiguity

提问by Ivan Dubrov

I am using git as a frontend to Subversion (via git svn).

我使用 git 作为 Subversion 的前端(通过 git svn)。

So, for every svn trunk/branch I have remote branch in git named "remotes/xxx". For example "remotes/trunk", "remotes/coolfeature".

因此,对于每个 svn 主干/分支,我在 git 中都有一个名为“remotes/xxx”的远程分支。例如“遥控器/主干”、“遥控器/coolfeature”。

Now I want have one "default" local branch for every remote branch, to use it for dcommit. The problem is that I want such branches to be named after Subversion branches, like "trunk", "coolfeature", so I have the following branches in git:

现在我希望每个远程分支都有一个“默认”本地分支,以将其用于 dcommit。问题是我希望这些分支以 Subversion 分支命名,比如“trunk”、“coolfeature”,所以我在 git 中有以下分支:

trunk
coolfeature
remotes/trunk
remotes/coolfeature

The problem is that every time I reference "trunk" or "coolfeature" git complains branch name is ambiguous. Not a big deal, but I feel uncomfortable.

问题是每次我引用“trunk”或“coolfeature”时,git 都会抱怨分支名称不明确。没什么大不了的,但我觉得不舒服。

The question is, how can I deal with that warning, assuming that simply renaming branches is not what I want to do. What are the best practices for such cases?

问题是,假设简单地重命名分支不是我想要做的,我该如何处理该警告。此类情况的最佳做法是什么?

采纳答案by Jason Voegele

If you pass the --prefix=svn/flag to the git svn clonecommand, then all of the Subversion branches would be named like remotes/svn/branchname. If this is acceptable to you, it fixes the "refname is ambiguous" warning. It also gives you a nice way of referring to the remote svn branches, as in for instance if you want to create a local tracking branch it would be something like:

如果将--prefix=svn/标志传递给git svn clone命令,则所有 Subversion 分支都将命名为remotes/svn/branchname. 如果这对您来说是可以接受的,它会修复“refname is ambiguous”警告。它还为您提供了一种引用远程 svn 分支的好方法,例如,如果您想创建一个本地跟踪分支,它将类似于:

$ git checkout -b branchname svn/branchname

$ git checkout -b branchname svn/branchname

The local branch then has the same name as the remote svn branch, and no ambiguous refname problem.

然后本地分支与远程 svn 分支具有相同的名称,并且没有歧义的 refname 问题。

回答by max

If you just want to get rid of warning, set core.warnAmbiguousRefsto false:

如果您只想摆脱警告,请设置core.warnAmbiguousRefsfalse

git config --global core.warnambiguousrefs false

If you want this behavior only for single repository, omit --globalflag.

如果您只希望此行为适用于单个存储库,请省略--global标志。

回答by Octavi Fornés

It can be possible that you have another 'trunk' and 'coolfeature' as a tag. In this case, git doesn't know if you refer to branch or tag. Rename the tags and check if git doesn't report "ambiguous" name

您可能有另一个“主干”和“coolfeature”作为标签。在这种情况下,git 不知道你指的是分支还是标签。重命名标签并检查 git 是否不报告“模棱两可”的名称

回答by Alex Brown

To avoid the conflict messages, when referring to local branches, prefix them with heads/

为避免冲突消息,在引用本地分支时,将它们作为前缀 heads/

for example, the conflicting branch topic

例如,冲突分支 topic

$ git diff topic remotes/topic
warning: reframe 'topic' is ambiguous.
...

becomes

变成

$ git diff heads/topic remotes/topic
...