Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Abort git merge using libgit2sharp

Tags:

libgit2sharp

In libgit2sharp I'm doing a fetch and merge for an upstream branch, and I want to be able to abort the merge similar to:

git merge --abort

when the MergeStatus is:

LibGit2Sharp.MergeStatus.Conflicts

Is this currently possible (using v.0.20.1)? If not, does anybody know what it would require to implement something like that?

like image 672
sitereactor Avatar asked Mar 18 '23 10:03

sitereactor


1 Answers

The git-merge --abort command is shorthand for git reset --merge, and both a git-reset --merge and a git-reset --hard will abort the merge and clean up the repository, differing in how they update modified files.

LibGit2Sharp does not currently offer a reset parallel to the merge option. However if you use the Repository.Reset method with the ResetMode.Hard option your merge will be aborted (though with git-reset --hard semantics).

like image 56
Edward Thomson Avatar answered Apr 29 '23 01:04

Edward Thomson