More and more Maven projects are switching from Subversion to Git, and the majority of those projects make the same mistake: They configure scm section of POM to point to remote repository, the same way they did it in Subversion

<scm>
<url>http://github.com/SpringSource/spring-batch</url>
<connection>scm:git:git://github.com/SpringSource/spring-batch.git</connection>
<developerConnection>scm:git:ssh://git@github.com/SpringSource/spring-batch.git</developerConnection>
</scm>

By doing this they lose the main benefit of Git. They become dependent on the remote machine. And when their release depends on the remote machine, that’s what happens: They need to release the project but the remote machine is down

The right way of configuring Git in Maven is following

<scm>
<url>scm:git:file://.</url>
<connection>scm:git:file://.</connection>
<developerConnection>scm:git:file://.</developerConnection>
</scm>

This configuration is universal, and it separates two orthogonal concerns: releases and remote copies.

Resources

  • Screencast that shows how to work with Git in Maven projects.