小编Nor*_*wan的帖子

如何提交和推送libgit2sharp

我刚刚下载了libgit2sharp的nugget包.我发现即使是基本的操作也很难.

我有一个现有的git仓库(远程和本地).我只需要在它发生时提交新的更改并将其推送到远程.

我有下面的代码来解释我做了什么.

string path = @"working direcory path(local)";
Repository repo = new Repository(path);
repo.Commit("commit done for ...");

Remote remote = repo.Network.Remotes["origin"];          
var credentials = new UsernamePasswordCredentials {Username = "*******", Password = "******"};
var options = new PushOptions();
options.Credentials = credentials;
var pushRefSpec = @"refs/heads/master";                      
repo.Network.Push(remote, pushRefSpec, options, null, "push done...");
Run Code Online (Sandbox Code Playgroud)

我应该在哪里指定远程网址?这也是做这些操作(提交和推送)的正确方法吗?

谢谢

libgit2 libgit2sharp

6
推荐指数
1
解决办法
5384
查看次数

标签 统计

libgit2 ×1

libgit2sharp ×1