Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 37 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

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

for example, the conflicting branch topic

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

becomes

$ git diff heads/topic remotes/topic
...
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com?utm_source=stackoverflow.com&amp;utm_medium=site-ui&amp;utm_campaign=footerlink\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.9.17.1862\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nos"], "copyright__copyright__copyright": ["|improve this answer\n\nTo avoid the conflict messages, when referring to local branches, prefix them with head/\n\nfor example, the conflicting branch topic\n\n$ git diff topic remotes/topic\nwarning: reframe 'topic' is ambiguous.\n...\n\nbecomes\n\n$ git diff heads/topic remotes/topic\n...\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}