无法使用libgit2sharp

时间:2018-12-17 14:00:25

标签: libgit2sharp

我使用以下代码将一些文件添加到本地存储库中,然后将其推送到远程。似乎可以创建远程分支,但不包括我要添加的文件。我不确定为什么,也不会抛出异常,您能帮忙提些建议吗?

                Remote remote = repo.Network.Remotes["origin"];
                string branchName = "B" + DateTime.UtcNow.ToString("yyyyMMddHHmmss");
                Branch branch = repo.CreateBranch(branchName, "origin/master");
                repo.Branches.Update(branch, delegate (BranchUpdater updater)
                {
                    updater.Remote = "origin";
                    updater.UpstreamBranch = branch.CanonicalName;
                });

                var pushOpt = new PushOptions();
                pushOpt.CredentialsProvider = (_url, _user, _cred) =>
                new UsernamePasswordCredentials { Username = "xxx", Password = "xxx" };

                File.WriteAllText(repoPath + @"/private/test5.txt", "123");
                DirectoryInfo directoryInfo = new DirectoryInfo(repoPath + "/private");
                var files = directoryInfo.GetFiles("*", SearchOption.AllDirectories).Select(f => f.FullName);
                Commands.Stage(repo, files);

                // commit autor
                Signature author = new Signature("sss", "sss@", DateTime.UtcNow);
                Signature committer = author;

                Commit commit = repo.Commit("onboard new artice", author, committer);
                repo.Network.Push(branch, pushOpt);`

0 个答案:

没有答案
相关问题