How to clone needed branch from a remote git repository?

Grgit.clone(dir: dir, uri: ‘git://’)

How do I specify branch? The default is ‘master’. Thanks

Follow the clone operation up with a checkout.

Tahks. But then get all the branches and then move to the right. And how to get a desired branch git repository?

That’s not how Git works. In Git you clone the entire repo (including all history, branches, tags, etc) locally and simply switch between branches. You might want to read up a little on Git if you are new to DVCS systems.

But if you look in the direction of other instruments, such as, for example, GitEye, it is possible to obtain the desired branch. I do not argue, perhaps in gredle it can not be done, but the tool pulls one branch, and it can’t gredle. Unfortunately!

Well, Gradle-git is a gradle plug-in that allows to use Groovy-git from gradle.
Then Groovy-git is a groovy wrapper around Jgit, nothing more.

So technically there is no gradle problem or missing functionalities here, only maybe lack of git support.

As pointed out by Mark, a git checkout would make you point to your desired branch.
You can always directly call a git command from a Gradle exec task if you prefer.

And Grgit.clone(…, refToCheckout:‘mybranch’)

Will check out a branch different than master directly after the clone operation.

According to
Jgit is able to clone only a single branch if needed, much like regular C git does.

You can submit a enhancement request to support this in grgit as well if you really want it.

Clearly, all thanks for the explanation!