Search code examples
javagitgradlegroovygrgit

Gradle Grgit : push to a specific remote branch


I am trying to push the local changes on the master branch to the remote master branch using this library for gradle https://ajoberstar.org/grgit/main/grgit-push.html:

grgit.push(remote:"master",tag:true)

It complains and i get this exception org.eclipse.jgit.errors.NoRemoteRepositoryException master not found how is that possible as master branch does exist at remote.

I even tried the following:

grgit.push(remote:"refs/heads/master",tags:true)
grgit.push(remote:"refs/remotes/origin/master",tags:true)

with no luck and same exception occurred as above.

But when i try with:

grgit.push(branch:all,tags:true)

that works but it pushes to all the branches at remote but that what i don't want. My requirement is to push to the specific branch. Like just master branch only.


Solution

  • Ok i have achieved this by:

    grgit.push(refsOrSpecs: ["refs/heads/master": "refs/heads/master" ],tags:true) 
    

    does the trick push to remote master branch only.