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

家住魔仙堡 提交于 2019-12-08 23:01:46

问题


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

So, for every svn trunk/branch I have remote branch in git named "remotes/xxx". For example "remotes/trunk", "remotes/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:

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.

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?


回答1:


If you pass the --prefix=svn/ flag to the git svn clone command, 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:

$ git checkout -b branchname svn/branchname

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




回答2:


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

git config --global core.warnambiguousrefs false

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




回答3:


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




回答4:


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

for example, the conflicting branch topic

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

becomes

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


来源:https://stackoverflow.com/questions/4644380/warning-refname-xxx-is-ambiguous-when-using-git-svn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!