I'm trying to replicate the outcome of the following command in git2go:
git merge -X theirs --no-ff -m "Commit msg" <commit>
I'm able to successfully fetch the upstream remote using remote.Fetch(nil, nil, "")
, but I cannot do the actual merge. This is the code I'm using for merging:
// get the upstream ref's annotated commit to merge in
head, _ := repo.Head()
upstream, _ := head.Branch().Upstream()
annotatedCommit, _ := repo.AnnotatedCommitFromRef(upstream)
// prepare merge and checkout options
mergeOpts, _ := git.DefaultMergeOptions()
mergeOpts.FileFavor = git.MergeFileFavorTheirs
checkoutOpts := git.CheckoutOpts{
Strategy: git.CheckoutUseTheirs,
}
// do the merge
err := repo.Merge([]*git.AnnotatedCommit{annotatedCommit}, &mergeOpts, &checkoutOpts)
// no error here
I understand that after this I need to check the index for any conflicts, and actually do the commit with the two parents, however I'm stuck here at the moment because the Merge()
doesn't appear to be doing anything (no merge, no checkout).