Maven SCM Git - Is it possible to check out just one branch? (--single-branch)

518 Views Asked by At

I'm using Maven SCM to checkout a Git repository. I only need to clone one branch so I would like to add '--single-branch' to the clone command.

The documentation doesn't mention anything about using custom options so I assume it isn't straightforward but maybe there is a workaround.

Is this possible?

1

There are 1 best solutions below

3
VonC On

My old answer from 2012 mentioning the single-branch option of git clone is not a duplicate of this question, which seeks to replicate that feature with the Maven SCM plugin.

Commit d327618 seems to indicate this is already the case:

clone only required branch

Git.cloneRepository().setURI( repository.getFetchUrl() ).setCredentialsProvider(
                              credentials ).setCloneAllBranches(true).setDirectory(
                              credentials ).setBranch( branch ).setDirectory(
                                           ^^^^^^^^^^^^^^^^^^^^