I need to run the command
git reset --hard origin <branch-name>
via JGit to reset corrupt local commits done by users, and I'm using following code:
git.reset().setRef(<branch-name>).setMode(ResetCommand.ResetType.HARD).call()
but it doesn't overwrites local commits and pointing to current remote HEAD.
I have tried with git.fetch()
and git.pull()
previous to git.reset()
but it doesn't work, is there another method I need to use?
Also, how to print result why it's failing, I see that .call()
returns Ref
but the Ref
object doesn't have messages, only ObjectId
.