我正在编写一个dotnet api,以便从github进行克隆,然后使用Libgit2sharp库将特定分支推送到AWS 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);
任何帮助表示赞赏...干杯
答案 0 :(得分:1)
尝试并使用complete refsepc when pushing
<refspec>
参数的格式是可选的加+
,后跟源对象<src>
,后跟冒号:
,后跟目标ref { {1}}。
在您的情况下:
<dst>