<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Robby on Rails: Lesson Learned: Git Ref Naming</title>
    <link>http://www.robbyonrails.com/articles/2008/09/18/lesson-learned-git-ref-naming</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>thoughts.sort_by{|t| t[:topic]}.collect </description>
    <item>
      <title>Lesson Learned: Git Ref Naming</title>
      <description>&lt;p&gt;Our team has been working our way into the Git world. One of our big client projects is now 100% git while the other is still on Subversion for another month or so. (I&amp;#8217;m getting by with &lt;a href="http://www.robbyonrails.com/articles/2008/04/10/git-svn-is-a-gateway-drug"&gt;git-svn&lt;/a&gt;, the gateway drug on that). We&amp;#8217;ve had pretty much nothing but success with Git for quite some time, but recently this repository started to get chaotic, which has eaten up time&amp;#8230; which isn&amp;#8217;t conducive to productivity.&lt;/p&gt;


	&lt;p&gt;So, I wanted to share a quick lesson that we learned today after scratching our head for a while. It&amp;#8217;s important that you avoid having a branch on a remote repository that shares the name of a tag in your local and/or remote repository.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;I REPEAT&lt;/span&gt;.&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s bad mojo to have a tag and branch share the same name. Things that you&amp;#8217;d expect &lt;em&gt;to just work&lt;/em&gt;... don&amp;#8217;t. This was causing us to see warnings and errors like the following, which we weren&amp;#8217;t really sure what to make of it.&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&amp;#8220;warning: refname &amp;#8216;staging&amp;#8217; is ambiguous.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&amp;#8220;error: src refspec staging matches more than one.&amp;#8221;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;This started about two weeks ago when we started a few new remote branches: &lt;em&gt;staging&lt;/em&gt; and &lt;em&gt;design&lt;/em&gt;. It seemed to be going okay but we managed to muck up things when we merged those two together and some of us were having success fetching/pulling/pushing to &lt;em&gt;staging&lt;/em&gt; and others were having to specify &lt;code&gt;:heads/staging&lt;/code&gt; and couldn&amp;#8217;t have a local branch named &lt;em&gt;staging&lt;/em&gt;. Needless to say, it was causing some problems and slowing us down.&lt;/p&gt;


	&lt;p&gt;This afternoon, we finally noticed in the GitHub interface that there was a tag named &lt;code&gt;staging&lt;/code&gt;. Hmm&amp;#8230; interesting. We verified this by using &lt;code&gt;git show-ref&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
git:(master): git show-ref | grep staging
6a18119ca9.... refs/heads/staging
82caa5f121.... refs/remotes/origin/staging
6a18119ca9.... refs/tags/staging
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Notice the tag reference at the end? After asking in #git, we were able to remove the tag with the following:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;git tag -d staging&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Then we needed to remove the reference of &lt;code&gt;staging&lt;/code&gt; on Github with &lt;code&gt;git push origin :staging&lt;/code&gt;. (we got rid of the remote branch temporarily as well so that we could clean this up).&lt;/p&gt;


	&lt;p&gt;The next step was to push our local branch back out to the remote branch &lt;code&gt;git push origin staging:staging&lt;/code&gt;.... and now we&amp;#8217;re back in business with a simple:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;git checkout --track -b staging origin/staging&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Anyhow, if you end up having those warnings/errors above, you might take a look at &lt;a href="http://www.kernel.org/pub/software/scm/git/docs/git-show-ref.html"&gt;git-show-ref&lt;/a&gt; to see what is in your local repository as this could be causing you some unnecessary headaches.&lt;/p&gt;


	&lt;p&gt;Kudos to &lt;a href="http://allisbe.com"&gt;Allison&lt;/a&gt; for taking the time to really read and digest the git documentation, which helped us figure this shit out. :-)&lt;/p&gt;


	&lt;p&gt;Since we&amp;#8217;re still learning to get around through things like this, if you have any more insight into this issue, feel free to help educate us a bit by sharing your wisdom in response to this post. :-)&lt;/p&gt;
</description>
      <pubDate>Thu, 18 Sep 2008 23:23:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a3d33486-399d-4bd6-99ce-934e1adce9dc</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2008/09/18/lesson-learned-git-ref-naming</link>
      <category>Programming</category>
      <category>git</category>
      <category>code</category>
      <category>source</category>
      <category>control</category>
      <category>lesson</category>
    </item>
  </channel>
</rss>
