Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Jgit Hard Reset Issue

Hi all, 

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.

      ResetCommand resetCmd = git.reset().setMode(ResetCommand.ResetType.HARD);


        try {

        } catch (GitAPIException e) {

Thanks and Regards,

Back to the top