<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sonatype Blog &#187; GIT</title>
	<atom:link href="http://www.sonatype.com/people/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sonatype.com/people</link>
	<description>Sonatype is transforming software development with tools, information and services that enable organizations to build better software, faster, using open-source components.</description>
	<lastBuildDate>Wed, 23 May 2012 14:24:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Goodbye SVN, Hello Git</title>
		<link>http://www.sonatype.com/people/2011/04/goodbye-svn-hello-git/</link>
		<comments>http://www.sonatype.com/people/2011/04/goodbye-svn-hello-git/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 13:00:12 +0000</pubDate>
		<dc:creator>Brian Demers</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[GIT]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=7844</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.sonatype.com/people/2011/04/goodbye-svn-hello-git/' addthis:title='Goodbye SVN, Hello Git '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>We are moving both our public and private source repositories to Git for a few reasons: Git works better for people with slow or lagging connections Branch management is easy Submitting patches via a pull request is easier to deal with than a patch attached to a bug report We started out with SVN mostly [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.sonatype.com/people/2011/04/goodbye-svn-hello-git/' addthis:title='Goodbye SVN, Hello Git '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>We are moving both our public and private source repositories to Git for a few reasons:</p>

<ul>
    <li>Git works better for people with slow or lagging connections</li>
    <li>Branch management is easy</li>
    <li>Submitting patches via a pull request is easier to deal with than a patch attached to a bug report</li>
</ul>

<p>We started out with SVN mostly because that was what everyone was used to. A year ago or so, one of our remote developers started using a git-svn mirror to remove some of the latency issues they had with SVN. Someone else put together a ten page wiki on how to <em>easily</em> use a git-svn mirror and push back to the canonical SVN repo. As time went on, interest in git grew and new modules were created in git, instead of our SVN repositories.  Finally there was a push to move everything to git.</p>

<p><span id="more-7844"></span></p>

<p>There were a couple different directory conventions used for our repositories.  Our Nexus SVN repository used the typical project-root/trunk,tags,branches, and git-svn worked nice right out of the box. Our other repositories lumped all modules under the trunk, tags, and branches folder (figure 1).</p>

<p>We decided to give each module its own git repository to better manage tags and branches related to the given module. This made the git import a pain, as you cannot just export tags/* (and tags/module-B-* will not work either), you need to be more selective and configure each tag to pull.</p>

<div id="attachment_8055" class="wp-caption alignnone" style="width: 495px"><a rel="attachment wp-att-8055" href="http://www.sonatype.com/people/2011/04/goodbye-svn-hello-git/spice-svn/"><img class="size-full wp-image-8055 " title="spice-svn" src="http://www.sonatype.com/people/wp-content/uploads/2011/04/spice-svn.png" alt="" width="485" height="679" /></a><p class="wp-caption-text">Figure 1.</p></div>

<!--more-->

<p>In a nut shell you need to:</p>

<p>(1) Create a new git repository.</p>

<p>$ git svn init &#8211;trunk=trunk/project &lt;svn-root&gt; &lt;repo-name&gt;</p>

<p>(2) Configure the specific tags you want to export (we use the Maven release plugin, so the tagging convention is the same)</p>

<p>$ git config &#8211;add svn-remote.svn.tags tags/{module-B-2.1, module-B-2.2}:refs/remotes/tags/*</p>

<p>(3) Fetch everything (for an automated way of generating an authors file see this <a href="http://technicalpickles.com/posts/creating-a-svn-authorsfile-when-migrating-from-subversion-to-git/" target="_blank">blog post</a>)</p>

<p>$ git svn fetch &#8211;authors-file=&lt;svn-authors-file&gt;</p>

<p>(4) Next you need to <a href="https://github.com/nothingmuch/git-svn-abandon" target="_blank">clean up the tags</a> and push.</p>

<p>If you script this, you end up with something like:</p>

<pre lang="bash" style="overflow:scroll;">
#!/bin/bash

CURRENT_PATH=`pwd`

# file based URL for reads
SVN_URL=file:///path/to/repositories/sonatype.org/spice
SVN_REMOTE_URL=https://svn.sonatype.org/spice
SVN_TAGS_DIR=tags
SVN_TAG_PREFIX=$1
SVN_TRUNK_DIR=trunk/${SVN_TAG_PREFIX}
SVN_AUTHORS=/path/to/svn-authors.txt

GIT_REPO_NAME=$1
GITHUB_USER=userid
GITHUB_TOKEN=xxx
GITHUB_TEAM_ID=1234
GITHUB_ORG=sonatype

# this is the magic, get the list of tags that match this project the output format looks like:
# tags/{module-1.0,module-1.2,module-2.1}
GIT_TAG_ARG=${SVN_TAGS_DIR}/\{`svn list ${SVN_URL}/${SVN_TAGS_DIR} | grep ${SVN_TAG_PREFIX} | sed 's_/__' | xargs -I {} echo -n ,{} | sed 's_^,__'`\}

#echo ${GIT_TAG_ARG}

# init git repo
git svn init --trunk=${SVN_TRUNK_DIR} ${SVN_URL} ${SVN_TAG_PREFIX}

#copy authors text to repo
cp ${SVN_AUTHORS} ${SVN_TAG_PREFIX}/.svn-authors.txt

# move to directory
cd ${SVN_TAG_PREFIX}

# make sure we have tags for this project
if [ `svn list ${SVN_URL}/${SVN_TAGS_DIR} | grep ${SVN_TAG_PREFIX} | wc -l` -gt 0 ]; then
  #configure the tags, we only want a subset of the tags, because we lumpped all the tags in a single place.
  git config --add svn-remote.svn.tags ${GIT_TAG_ARG}:refs/remotes/tags/*
fi

#fetch
git svn fetch --authors-file=.svn-authors.txt
# make sure there are no errors before we continue
if [ "$?" -ne "0" ]; then
  echo "Error while fetching, see above"
  exit 1
fi

git update-ref -d master

##########################################################
# fix the tags, from: https://github.com/nothingmuch/git-svn-abandon
##########################################################

# create annotated tags out of svn tags
git for-each-ref --format='%(refname)' refs/remotes/tags/* | while read tag_ref; do
    tag=${tag_ref#refs/remotes/tags/}
    tree=$( git rev-parse "$tag_ref": )

    # find the oldest ancestor for which the tree is the same
    parent_ref="$tag_ref";
    while [ $( git rev-parse --quiet --verify "$parent_ref"^: ) = "$tree" ]; do
        parent_ref="$parent_ref"^
    done
    parent=$( git rev-parse "$parent_ref" );

    # if this ancestor is in trunk then we can just tag it
    # otherwise the tag has diverged from trunk and it's actually more like a
    # branch than a tag
    merge=$( git merge-base "refs/remotes/trunk" $parent );
    if [ "$merge" = "$parent" ]; then
        target_ref=$parent
    else
        echo "tag has diverged: $tag"
        target_ref="$tag_ref"
    fi

    # create an annotated tag based on the last commit in the tag, and delete the "branchy" ref for the tag
    git show -s --pretty='format:%s%n%n%b' "$tag_ref" | \
    perl -ne 'next if /^git-svn-id:/; $s++, next if /^\s*r\d+\@.*:.*\|/; s/^ // if $s; print' | \
    env GIT_COMMITTER_NAME="$(  git show -s --pretty='format:%an' "$tag_ref" )" \
        GIT_COMMITTER_EMAIL="$( git show -s --pretty='format:%ae' "$tag_ref" )" \
        GIT_COMMITTER_DATE="$(  git show -s --pretty='format:%ad' "$tag_ref" )" \
        git tag -a -F - "$tag" "$target_ref"

    git update-ref -d "$tag_ref"
done

# create local branches out of svn branches
git for-each-ref --format='%(refname)' refs/remotes/ | while read branch_ref; do
    branch=${branch_ref#refs/remotes/}
    git branch "$branch" "$branch_ref"
    git update-ref -d "$branch_ref"
done

# remove merged branches
git for-each-ref --format='%(refname)' refs/heads | while read branch; do
    git rev-parse --quiet --verify "$branch" || continue # make sure it still exists
    git symbolic-ref HEAD "$branch"
    git branch -d $( git branch --merged | grep -v '^\*' )
done
##########################################################
# done fixing tags
##########################################################

# we should already be on the master, but lets make sure
git checkout master

##
# Use the Github API to create a repo and add it to the team.
##

#create github repo
curl -F "login=${GITHUB_USER}" -F "token=${GITHUB_TOKEN}" https://github.com/api/v2/json/repos/create -F "name=${GITHUB_ORG}/${GIT_REPO_NAME}" -F "has_issues=false" -F "has_downloads=false" -F "has_wiki=false"  --request POST

#add the dev team to the repo
curl -F "login=${GITHUB_USER}" -F "token=${GITHUB_TOKEN}" -F "name=${GITHUB_ORG}/${GIT_REPO_NAME}" http://github.com/api/v2/json/teams/${GITHUB_TEAM_ID}/repositories

# set the origin
git remote add origin git@github.com:${GITHUB_ORG}/${GIT_REPO_NAME}.git
#push it all
git push --tags origin master

#go back to where we started
cd ${CURRENT_PATH}

# some reminders so we do not forget the manual steps
echo "--${GIT_REPO_NAME}--" &gt;&gt; migrate.out
echo "You should now review the git repo at: https://github.com/${GITHUB_ORG}/${GIT_REPO_NAME} then remove the svn repo with:" &gt;&gt; migrate.out
echo "$ svn rm ${SVN_REMOTE_URL}/${SVN_TRUNK_DIR} -m  \"Moved to github: https://github.com/${GITHUB_ORG}/${GIT_REPO_NAME}\"" &gt;&gt; migrate.out
echo "Do not forget to update the grid: https://grid.sonatype.org/ci/\" to use: git://github.com/${GITHUB_ORG}/${GIT_REPO_NAME}.git &gt;&gt; migrate.out
echo "Add redirect from ${SVN_REMOTE_URL}/${SVN_TRUNK_DIR} to https://github.com/${GITHUB_ORG}/${GIT_REPO_NAME}" &gt;&gt; migrate.out
echo "" &gt;&gt; migrate.out</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sonatype.com/people/2011/04/goodbye-svn-hello-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Next Generation Maven Development Stack @ JFokus</title>
		<link>http://www.sonatype.com/people/2010/01/next-generation-maven-development-stack/</link>
		<comments>http://www.sonatype.com/people/2010/01/next-generation-maven-development-stack/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 05:21:05 +0000</pubDate>
		<dc:creator>Jason van Zyl</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[m2eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[GIT]]></category>
		<category><![CDATA[guice]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[jfokus]]></category>
		<category><![CDATA[peaberry]]></category>
		<category><![CDATA[polyglot]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=4113</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.sonatype.com/people/2010/01/next-generation-maven-development-stack/' addthis:title='Next Generation Maven Development Stack @ JFokus '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>For my talk today at JFokus today I&#8217;ve taken the liberty of starting some notes for folks interested in attending. There&#8217;s a lot to cover and so I thought I would try the approach of providing some material up front so the session can be more of a dialog. I&#8217;m going to attempt to cover [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.sonatype.com/people/2010/01/next-generation-maven-development-stack/' addthis:title='Next Generation Maven Development Stack @ JFokus '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>For my talk today at JFokus today I&#8217;ve taken the liberty of starting some notes for folks interested in attending. There&#8217;s a lot to cover and so I thought I would try the approach of providing some material up front so the session can be more of a dialog. I&#8217;m going to attempt to cover everything in the picture below and save the demos folks might want to see for the Sonatype booth. Happy to chat with folks and do any demos before and after the presentation. Just stop by!</p>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2010/01/Stack1.png" alt="Stack.png" border="0" /></p>

<h3>Maven Stack Infrastructure</h3>

<p>I&#8217;m going to talk about some of the under pinnings of the technologies we&#8217;re using as part of our Maven work. Why we selected the technologes and some of the current work that&#8217;s happening.
<span id="more-4113"></span></p>

<ul>
<li><a href="http://code.google.com/p/google-guice/">Guice</a></li>
<li><a href="http://www.sonatype.com/people/2010/01/from-plexus-to-guice-1-why-guice/">From Plexus to Guice (#1): Why Guice?</a></li>
<li><a href="http://www.sonatype.com/people/2010/01/from-plexus-to-guice-2-the-guiceplexus-bridge-and-custom-bean-injection/">From Plexus to Guice (#2): The Guice/Plexus Bridge and Custom Bean Injection</a></li>
<li><a href="http://www.sonatype.com/people/2010/01/from-plexus-to-guice-3-creating-a-guice-bean-extension-layer/">From Plexus to Guice (#3): Creating a Guice Bean Extension Layer</a></li>
<li><a href="http://code.google.com/p/peaberry/">Peaberry</a></li>
<li><a href="http://incubator.apache.org/shiro/">Apache Shiro</a></li>
<li><a href="http://enunciate.codehaus.org/">Enunciate</a></li>
</ul>

<h3>Maven</h3>

<p>There are several develops going on in the various Maven projects. Maven 3.x is on the way, but we have some very interesting work happing with OSGi within our Tycho project. The Flexmojos project and NAR (the C/++ framework for Maven) are also popular.</p>

<h4>Tycho</h4>

<ul>
<li><a href="http://tycho.sonatype.org/">Tycho Site</a></li>
<li><a href="http://github.com/sonatype/sonatype-tycho">Tycho @ Github</a></li>
<li><a href="http://github.com/sonatype/m2eclipse-tycho">Tycho/PDE Integration</a></li>
<li><a href="http://wiki.eclipse.org/Equinox_p2">P2 Site</a></li>
</ul>

<h4>Flexmojos</h4>

<ul>
<li><a href="http://flexmojos.sonatype.org/">Flexmojos Site</a></li>
</ul>

<h4>NAR</h4>

<ul>
<li><a href="http://duns.github.com/maven-nar-plugin/">NAR Site</a></li>
<li><a href="http://github.com/sonatype/maven-nar-plugin">NAR @ Github</a></li>
</ul>

<h3>M2Eclipse</h3>

<p>The primary IDE integration we work on at Sonatype. The most important thing to talk about in M2Eclipse is the configuration framework.</p>

<ul>
<li><a href="http://m2eclipse.sonatype.org/">M2Eclipse Site</a></li>
</ul>

<h3>Hudson</h3>

<p>Most of the work we&#8217;ve been doing on Hudson is still not really good enough for public consumption but we&#8217;re testing the changes we&#8217;re making on the Sonatype grid.</p>

<p><a href="https://hudson.dev.java.net/">Hudson Site</a></p>

<h3>Nexus</h3>

<ul>
<li><a href="http://nexus.sonatype.org">Nexus Site</a></li>
<li><a href="http://www.sonatype.com/people/2010/01/nexus-oss-ecosystem/">Nexus: Improving Maven Central and Supporting the Maven Ecosystem</a></li>
<li><a href="http://www.sonatype.com/people/2010/01/10-questions/">Selecting OSS Software: 10 Questions Answered for Sonatype Nexus</a></li>
<li><a href="http://nexus.sonatype.org/oss-repository-hosting.html">OSS Repository Hosting</a></li>
<li><a href="http://bundles.sonatype.org/index.html#welcome">OSGi Central</a></li>
<li>Ruby Central (We&#8217;re working on making that publicly available</li>
</ul>

<h3>Proviso</h3>

<p>Proviso is not publicly released yet, but Alin and I have been working together to get our provisioning framework ready for a public release.</p>

<h3>Git</h3>

<p>We are starting to use Git heavily and soon likely exclusively. We are helping out on the EGit, and JGit projects at Eclipse and we&#8217;re trying to put a little Git server together based on JGit, MINA, and Apache Shiro.</p>

<ul>
<li><a href="http://www.eclipse.org/jgit/">JGit Site</a></li>
<li><a href="http://www.eclipse.org/egit/">EGit Site</a></li>
<li><a href="http://aniszczyk.org/2010/01/25/egit-and-jgit-builds-available/">Tycho building EGit/JGit</a></li>
<li><a href="http://github.com/sonatype/sshjgit">SShJGit @ Github</a></li>
</ul>

<h3>Maven Extensions</h3>

<p>I&#8217;ll chat about these in the talk.</p>

<ul>
<li><a href="http://polyglot.sonatype.org/">Polyglot Maven Site</a></li>
<li><a href="http://github.com/sonatype/polyglot-maven">Polyglot Maven @ Github</a></li>
<li><a href="http://mvnsh.sonatype.org">Maven Shell</a></li>
<li><a href="https://github.com/sonatype/mvnsh">Maven Shell @ Github</a></li>
</ul>

<p>I&#8217;ll likely keep adding to the entry leading up the talk, but I thought I would get the ball rolling!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sonatype.com/people/2010/01/next-generation-maven-development-stack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven Tips and Tricks: Using GitHub</title>
		<link>http://www.sonatype.com/people/2009/09/maven-tips-and-tricks-using-github/</link>
		<comments>http://www.sonatype.com/people/2009/09/maven-tips-and-tricks-using-github/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 20:56:22 +0000</pubDate>
		<dc:creator>Tim O'Brien</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[GIT]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.sonatype.com/people/?p=2813</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.sonatype.com/people/2009/09/maven-tips-and-tricks-using-github/' addthis:title='Maven Tips and Tricks: Using GitHub '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Sonatype uses GitHub to host a number of projects including all of our books. It has been a very valuable tool for us, and we&#8217;ve already seen great benefits. The social, interactive nature of the tool allows people interested in the book to keep up with the development of the content, and we&#8217;ve already had [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.sonatype.com/people/2009/09/maven-tips-and-tricks-using-github/' addthis:title='Maven Tips and Tricks: Using GitHub '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/09/github-logo.png" alt="github-logo" title="github-logo" width="138" height="71" class="alignright size-full wp-image-2816" /></p>

<p>Sonatype uses GitHub to host a number of projects including all of our books.  It has been a very valuable tool for us, and we&#8217;ve already seen great benefits.   The social, interactive nature of the tool allows people interested in the book to keep up with the development of the content, and we&#8217;ve already had a few contributors show up and help us write more content.   Contributors can fork our books, add whole sections or correct typod and then make a simple pull request that notifies us of the changes.  Because we find it so useful, I thought I&#8217;d take some time to detail the process of connecting a new Maven project to GitHub.    The following post details the process of creating a new GitHub repository, importing a Maven project, and then configuring the SCM element in your project&#8217;s POM.   Once you&#8217;ve done that, you can start using the Maven Release plugin to automate the SCM operations that accompany a release.</p>

<p><span id="more-2813"></span></p>

<p><b>Step 1.</b> <b>Install Git on your local machine.</b>   If you don&#8217;t know how to do this, don&#8217;t worry, GitHub is an example of a site that values great documentation, and they have a number of helpful guides for <a href="http://help.github.com/msysgit-key-setup/">Windows</a>, <a href="http://help.github.com/mac-git-installation/">Mac OS X</a>, and <a href="http://help.github.com/linux-key-setup/">Linux</a>.</p>

<p><b>Step 2.</b> <b>Sign up for a GitHub account if you don&#8217;t already have one.</b></p>

<p><b>Step 3.</b> Once you create an account, you&#8217;ll need to <b>load your public SSH key into GitHub</b>.     When you run git, or more importantly when Maven runs Git, it isn&#8217;t going to prompt you for a username and password, it relies upon key-based authentication in SSH.   Again, if you don&#8217;t know how to do this, follow one of these GitHub help documents: <a href="http://help.github.com/msysgit-key-setup/">Windows</a>, <a href="http://help.github.com/mac-git-installation/">Mac OS X</a>, and <a href="http://help.github.com/linux-key-setup/">Linux</a>.</p>

<p>To add a public key (you can have several associated with your account), login, click on &#8220;account&#8221;, and then click on &#8220;add another public key&#8221; under the section that lists public keys.</p>

<p><b>Step 4.</b> If you don&#8217;t already have Maven installed, download it from http://maven.apache.org and add it to your PATH.      If you are looking for more detailed instructions, we have an <a href="http://www.sonatype.com/books/maven-book/reference/installation.html">entire chapter on the Maven installation process</a> in Maven: The Definitive Guide.</p>

<p>If you can run &#8220;mvn&#8221; and &#8220;git&#8221; from the command line, you are ready to start creating a project and importing it into a new GitHub repository.</p>

<p><b>Step 5.</b> Create a new Maven project using the archetype:generate goal.   Run &#8220;mvn archetype:generate&#8221; from the command line, supply a groupId, artifactId, package name, version, and use the default quickstart Archetype.</p>

<p>For the purposes of this blog entry, I&#8217;ll assume you used the following parameters:</p>

<ul>
  <li>groupId: com.sonatype.blog</li>
  <li>artifactId: git-demo</li>
  <li>version: 1.0-SNAPSHOT</li>
  <li>package name: com.sonatype.blog</li>
</ul>

<p><b>Step 6.</b> Change directories into the newly created &#8220;git-demo&#8221; directory and run &#8220;mvn clean install&#8221; to make sure that you can successfully build the quickstart project.</p>

<p><b>Step 7.</b> Create a new GitHub repository.    Login, and click on the GitHub logo in the upper left-hand of the web page, you should then see a list of your repositories on the right-hand side of the screen.   Click on &#8220;Create a New One&#8221; next to the words &#8220;Your Repositories&#8221; (as shown below)</p>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/09/new-github-repo.png" alt="new-github-repo" title="new-github-repo" width="368" height="83" class="aligncenter size-full wp-image-2815" /></p>

<p>For the purposes of this post, I used the following values:</p>

<p><img src="http://www.sonatype.com/people/wp-content/uploads/2009/09/new-git-repo-values.png" alt="new-git-repo-values" title="new-git-repo-values" width="444" height="307" class="aligncenter size-full wp-image-2817" /></p>

<p>Once your new GitHub repository is created, GitHub will load the repository and show you some instructions.   At this point, you&#8217;ll want to import the project you just created into your new GitHub repository.</p>

<p><b>Step 8.</b> From the &#8220;git-demo&#8221; project directory, execute the following commands (substitute your Git user name for &#8220;tobrien&#8221; in the commands listed below):</p>

<pre>
   mvn clean
   git init
   git add -A
   git commit -m "Importing the git-demo project"
   git remote add origin git@github.com:tobrien/git-demo.git
   git push origin master
</pre>

<p>After running these commands, return to the GitHub interface, and you should see that your GitHub project is now full of the contents of the git-demo project.   While you&#8217;ve added the project to GitHub, you still haven&#8217;t configured your Maven project to interact with GitHub, let&#8217;s do that now&#8230;.</p>

<p><b>Step 9.</b> Open up the pom.xml file of the git-demo project and add the following scm element right before the closing project element.  Make sure to substitute your account name for the instances of &#8220;tobrien&#8221; in the XML snippet shown below:</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;connection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>scm:git:git@github.com:tobrien/git-demo.git<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/connection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>scm:git:git@github.com:tobrien/git-demo.git<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;developerConnection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>scm:git:git@github.com:tobrien/git-demo.git<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/developerConnection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scm<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>After the scm element, add the following build element which forces Maven to use the most recent version of the maven-release-plugin:</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-release-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.0-beta-9<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<p>Add the pom.xml to the next commit, commit your changes, and push to GitHub:</p>

<pre>
  git add pom.xml
  git commit -m "Configuring POM for GitHub project"
  git push
</pre>

<p><b>Step 10.</b> Run the Maven Release Plugin to cut the 1.0 release.   Since our quickstart project is at version 1.0-SNAPSHOT, running &#8220;mvn release:prepare&#8221; is going to update the version to 1.0, commit the changes to a git-demo-1.0 tag, and then increment the version to 1.1-SNAPSHOT.   Do to this, run &#8220;mvn release:prepare&#8221;.</p>

<pre>
canning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building git-demo
[INFO]    task-segment: [release:prepare] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [release:prepare {execution: default-cli}]
[INFO] Resuming release from phase 'scm-check-modifications'
[INFO] Verifying that there are no local modifications...
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git status
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] nothing added to commit but untracked files present (use "git add" to track)
[INFO] Checking dependencies and plugins for snapshots ...
What is the release version for "git-demo"? (com.sonatype.demo:git-demo) 1.0: :
What is SCM release tag or label for "git-demo"? (com.sonatype.demo:git-demo) git-demo-1.0: :
What is the new development version for "git-demo"? (com.sonatype.demo:git-demo) 1.1-SNAPSHOT: :
[INFO] Transforming 'git-demo'...
[INFO] Not generating release POMs
[INFO] Executing goals 'clean verify'...
[WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] [INFO] Scanning for projects...
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building git-demo
[INFO] [INFO]    task-segment: [clean, verify]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [clean:clean {execution: default-clean}]
[INFO] [INFO] [resources:resources {execution: default-resources}]
[INFO] [WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] [INFO] skip non existing resourceDirectory /Users/tobrien/temp/git-demo/src/main/resources
[INFO] [INFO] [compiler:compile {execution: default-compile}]
[INFO] [INFO] Compiling 1 source file to /Users/tobrien/temp/git-demo/target/classes
[INFO] [INFO] [resources:testResources {execution: default-testResources}]
[INFO] [WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] [INFO] skip non existing resourceDirectory /Users/tobrien/temp/git-demo/src/test/resources
[INFO] [INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] [INFO] Compiling 1 source file to /Users/tobrien/temp/git-demo/target/test-classes
[INFO] [INFO] [surefire:test {execution: default-test}]
[INFO] [INFO] Surefire report directory: /Users/tobrien/temp/git-demo/target/surefire-reports
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.sonatype.demo.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.032 sec
[INFO]
[INFO] Results :
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] [INFO] [jar:jar {execution: default-jar}]
[INFO] [INFO] Building jar: /Users/tobrien/temp/git-demo/target/git-demo-1.0.jar
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESSFUL
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 5 seconds
[INFO] [INFO] Finished at: Tue Sep 08 17:35:35 CDT 2009
[INFO] [INFO] Final Memory: 24M/80M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git add pom.xml
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git status
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git commit --verbose -F /var/folders/qR/qRpEDfQcFPmRZpsXgPHOok+++TM/-Tmp-/maven-scm-2142457355.commit pom.xml
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git push
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Tagging release with the label git-demo-1.0...
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git tag -F /var/folders/qR/qRpEDfQcFPmRZpsXgPHOok+++TM/-Tmp-/maven-scm-1032558296.commit git-demo-1.0
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git push origin git-demo-1.0
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git ls-files
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Transforming 'git-demo'...
[INFO] Not removing release POMs
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git add pom.xml
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git status
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git commit --verbose -F /var/folders/qR/qRpEDfQcFPmRZpsXgPHOok+++TM/-Tmp-/maven-scm-1856882176.commit pom.xml
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Executing: /bin/sh -c cd /Users/tobrien/temp/git-demo &#038;&#038; git push
[INFO] Working directory: /Users/tobrien/temp/git-demo
[INFO] Release preparation complete.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24 seconds
[INFO] Finished at: Tue Sep 08 17:35:45 CDT 2009
[INFO] Final Memory: 14M/80M
[INFO] ------------------------------------------------------------------------
</pre>

<p><b>Step 10.</b>  After a release:prepare, the logical next step is to run a release:perform.   release:perform exports the newly created git-demo-1.0 tag, builds the project and then calls deploy.   If you run &#8220;release:perform&#8221; without a distributionManagement section of your POM you are going to get an error, but run it anyway just to see what the Maven Release Plugin does.</p>

<p>The next step on your journey involves the configuration of the distirbution management settings and the deployment of your project&#8217;s artifacts to a repository manager.    Once you do that, you can completely automate the process of releasing, updating source control, and distributing your binary artifacts to a repository manager.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sonatype.com/people/2009/09/maven-tips-and-tricks-using-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

