0

I've been searching the JGit API for hours, trying to figure out how to reach a similar behavior to git checkout -m file.

What I need is a programmatic way to revert the local repository (or a single file) to the state it was when it had conflicts.

Imagine the following scenario:

  1. I have a conflict in 'file1' when trying to merge two branches.
  2. I start making changes to 'file1' to solve the conflicts.
  3. At some point, I want to discard the changes made on 'file1' and go back to the conflict state, with all conflict 'marks'.

Is it possible to achieve this using JGit API?

  • If you don't mind losing all changes, you could abort the entire merge operation as described here: https://stackoverflow.com/questions/29807016/abort-merge-using-jgit – Rüdiger Herrmann Apr 18 '19 at 07:21
  • Thanks for the suggestion @RüdigerHerrmann. Unfortunately, I need to reset to the state after the merge operation was performed i.e. the conflict state. Returning to the state pre-merge would imply that I need to make the merge again. However, I cannot be sure about which merge algorithm was used to generate the conflict. My initial stage is the point where there are already conflicts in the project. Thanks anyway. – Heleno Campos Apr 19 '19 at 13:32

0 Answers0