【发布时间】:2020-03-28 00:33:03
【问题描述】:
我正在编写一个 dotnet api 从 github 克隆,然后使用 Libgit2sharp 库将特定分支推送到 AWS codecommit。
- 我在 gitHubRepo 中有两个分支,origin/release 和 origin/refactor。
- origin/release 是默认的 git 分支
- 我想克隆 gitHubRepo,并将 origin/refactor 分支推送到 codecommit
问题: 我似乎无法让它将我指定的分支推送到代码提交,它似乎总是推送设置为 HEAD 的内容。我不知道如何更改 HEAD,甚至不知道这是否是问题。
代码片段:
var baseRefBranch = gitHubRepo.Branches[$"origin/refactor"];
if (baseRefBranch == null) throw new Exception("refactor branch was null...");
logger.LogInformation($"Checking out branch: {baseRefBranch.CanonicalName}");
Commands.Checkout(gitHubRepo, baseRefBranch);
logger.LogInformation($"Update branch {baseRefBranch.CanonicalName}, set remote name {codeCommitRemote.Name}, set upstreamBranch to {baseRefBranch.CanonicalName}");
gitHubRepo.Branches.Update(baseRefBranch,
b => b.Remote = codeCommitRemote.Name,
b => b.UpstreamBranch = baseRefBranch.CanonicalName);
var refSpec = $"+{baseRefBranch.CanonicalName}";
logger.LogInformation($"Trying to push to remote: {codeCommitRemote.Name}, refSpec: {refSpec}");
gitHubRepo.Network.Push(codeCommitRemote, refSpec, pushOptions);
任何帮助表示赞赏...干杯
【问题讨论】:
标签: git .net-core libgit2sharp aws-codecommit