Shelljs exec failed on git cherry-pick

341 Views Asked by At

I have a script that cherry-picks a commit using shelljs.

Here is my LOC that does cherry-picking using shelljs.

shell.exec('git cherry-pick commitid -X theirs');
Note: commitid = sha of commit I want to cherry-pick.

shelljs is throwing the following error:

fatal: bad object: commitid 

e.g

fatal: bad object: 7854484884 (commitid)
1

There are 1 best solutions below

0
On BEST ANSWER

I found out the issue.

My project structure looks like this:

project1 (git repo)
  cherrypick.js
  project2 (another git repo)

I wanted to cherry-pick a commit in project2 and merge it in different branch.

But the code written was in project1. Hence I had to add this line and it works.

shell.exec('cd project2');
shell.exec('git cherry-pick commitid -X theirs');