LibGit2Sharp-在master分支中合并开发

时间:2018-09-21 11:22:46

标签: libgit2sharp

我想将自己的开发与LibGit2Sharp合并到我的master分支中,但是在GitHub wiki of LibGit2Sharp上找不到任何示例。 我该怎么办?

代码段:

using (var repo = new Repository(repoDirectory))
{
    var masterBranch = repo.Branches["master"];
    var developBranch = repo.Branches["develop"];

    Commands.Checkout(repo, masterBranch);
    // merge dev in master
    // tag master
    Commands.Checkout(repo, developBranch);
    // merge master in dev
}

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,我不确定是否可以通过其他方式完成,但我可以。

using (var repo = new Repository(repoDirectory))
{
    var masterBranch = repo.Branches["master"];
    var developBranch = repo.Branches["develop"];
    var merger = new Signature(AuthorName, AuthorEmail, DateTime.Now);

    Commands.Checkout(repo, masterBranch);
    repo.Merge(developBranch, merger, new MergeOptions());

    repo.ApplyTag("v0.1");

    Commands.Checkout(repo, developBranch);
    repo.Merge(masterBranch, merger, new MergeOptions());
}