没有完整的分支克隆。
是否可以:
下面的代码提交,但我无法找到推送方式。
string result = Repository.Init(fullLocalPath);
using (var repo = new Repository(result))
{
Remote remote = repo.Network.Remotes.Add("origin", url);
//fetch remote
FetchOptions fo = new FetchOptions { CredentialsProvider = (_url, _usernameFromUrl, _cred)
=> gitUserCred};
repo.Fetch(remote.Name, fo);
//reference fetched tracked branch.
Branch trackedBranch = repo.Branches[trackedBranchName];
//create a local branch
var localBranch = repo.CreateBranch(testBranchName, trackedBranch.Tip);
//map local to tracked.
repo.Branches.Update(localBranch,
b => b.Remote = remote.Name,
b => b.UpstreamBranch = localBranch.CanonicalName);
//switch to local branch
CheckoutOptions co = new CheckoutOptions { CheckoutModifiers= CheckoutModifiers.Force };
repo.CheckoutPaths(localBranch.Name, fileList.AsEnumerable<string>(), co);
foreach (string file in fileList)
{
//change files here.
//then stage
repo.Stage(localFileFull);
}
Commit c = repo.Commit("Persisting the files locally");
//commit
PushOptions po = new PushOptions();
var pushRefSpec = $"{c.Sha}:refs/heads/master";
po.CredentialsProvider = (_url, _usernameFromUrl, _cred) => gitUserCred;
repo.Network.Push(remote, c.Sha, pushRefSpec, po, testSignature, "partial push");
}