Experienced that the following sequence of operations are different between native git and jgit
1. Using native git:
Do a git hard reset when there is a merging error for an untracked file (there is such a file in the remote repo, and git is complaining that local untracked file will beÂoverwrittenÂ- error: Untracked working tree file 'xxx/yyy' would be overwritten by merge.)Â
Â
After the the hard reset, the working directory is clean and the untracked local file is replaced by the file from the remote branch.
2. Using JGit:Â
In a similar situation as explained above, when we try to do a git pull, aÂCheckoutConflictException is thrown. However, when I tried to do a hard reset, the untracked conflicting file was not replaced by the file from the remote repository. The local file was left as a deleted file ready to be committed. (Saw this from the git status). I used the code [1] to do the hard reset.
What is the reason for this? Is there any issue with the code that I'm using or in the approach? I'm using jgit 2.3.1.
[1].Â
   ResetCommand resetCmd = git.reset().setMode(ResetCommand.ResetType.HARD);
    resetCmd.setRef("origin/master");
    try {
      resetCmd.call();
    } catch (GitAPIException e) {
      e.printStackTrace();
    }
--
Thanks and Regards,
Isuru