How to hard reset from one git branch to other in JGit?

后端 未结 1 362
故里飘歌
故里飘歌 2021-01-19 06:25

I have two branches one is master and another one level1. Now level1 is the latest I need to hard reset master to level1 normally in git bash I can do that by following comm

1条回答
  •  醉话见心
    2021-01-19 07:20

    By default the ResetCommand resets to HEAD. To reset to another branch, you need to specify this branch with setRef().

    For example:

    git.reset().setMode(ResetType.HARD).setRef("refs/heads/level1").call();
    

    The above command will let the current branch point to the latest commit of level1 and checkout its state into the work directory .

    0 讨论(0)
提交回复
热议问题