title: how to switch maven local repository cache when git branch is switched
body: <p>I use maven and git in a project. The git repository contains a maven project with several subprojects in separate directories with own pom files. I use git local branches and I switch between these branches quite often. Whenever I switch the git local branch I need to call <code>mvn install</code> to refresh the local maven  repository cache in <code>$HOME/.m2</code>. The git branch switch is fast but the local local maven cache rebuild takes more than 20 minutes. If I do not rebuild it then a subproject build fails because the subprojects depends on other subprojects.</p>
  
  <p>My intention is to create a git hook for post-merge and make a separate maven repository cache for each branch. The git hook then can call something like <code>ln -s branch-specific-cache $HOME/.m2</code>.</p>
  
  <p>But I think that such a solution must already exist and I do not want to invent a wheel. Is there an existing mechanism that allows following?</p>
  
  <ul>
  <li>change the local maven cache when a git branch is changed</li>
  <li>create a copy of the local maven cache when a git branch is created</li>
  </ul>