0

My requirement is to add the last commit of branch 'A' to branch 'B'. I did some research and found out 'cherry picking' can be a good solution to this.I want to write a gradle task which will be doing this operation. So, I do something like this:

task CopyCommits() <<{
def grgit = org.ajoberstar.grgit.Grgit.open(dir: project.parent.projectDir)
grgit.checkout(branch: 'B')
'git cherry-pick 2133467'.execute().text.trim()

}

Branch A is my local branch. The above task doesn't perform the required operation.

sver
  • 866
  • 1
  • 19
  • 44

1 Answers1

0

I was not able to use cherry-pick here since I want to push all commits to the other branch. this worked for me here:

task PushChanges() <<{
 def grgit = org.ajoberstar.grgit.Grgit.open(dir: project.parent.projectDir)
'git push origin A:B'.execute().text.trim()
}
sver
  • 866
  • 1
  • 19
  • 44