Search code examples
azure-devopslerna

Lerna Detached git HEAD error in Azure devOps pipeline


In my pipeline, I just simply did the following in one of my steps

lerna publish --yes

And I received error

lerna ERR! ENOGIT Detached git HEAD, please checkout a branch to choose versions.

I think it probably be something trivial, really appreciated for any advice.


Solution

  • You didn't do anything wrong -- the default behavior of pipelines is to checkout a commit, not a branch, thus detaching HEAD. I'm not familiar with Lerna or what "publish" does, so I can't tell you if what you're trying to do is going to be a bad idea or not, but you can simply checkout the appropriate branch before running the command.