git c#, commit本地,push服务器
//ok
private static void push()
{
string wkDir = @"E:\DotNet2010\单位工程\Git.Client\lib2Test\ConsoleApplication1\bin\Debug\D2Git\.git";
using (var repo = new Repository(wkDir))
{
//此时必须保证存在 one.txt,two.txt 两个文件
string fname = "one.txt";
repo.Index.Stage(fname);
repo.Commit("add one", Constants.Signature, Constants.Signature);
fname = "two.txt";
repo.Index.Stage(fname);
repo.Commit("add two", Constants.Signature, Constants.Signature);
var nk = repo.Network;
PushOptions po = new PushOptions
{
CredentialsProvider = (x, y, z) => new UsernamePasswordCredentials { Username = "admin", Password = "admin" }
};
nk.Push(repo.Head, po);
nk.Push(repo.Branches["master"], po);
}
}
鄙视csdn的保存速度,园子速度超快!

浙公网安备 33010602011771号