码迷,mamicode.com
首页 > Windows程序 > 详细

git for c#, commit本地,pushserver

时间:2017-04-14 18:38:46      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:test   project   public   rom   net   epo   ide   datetime   oid   

//ok
        private static void push()
        {
            string wkDir = @"E:\DotNet2010\单位project\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);

            }
        }


    public static class Constants
    {
        public static readonly Signature Signature = new Signature("javasuki", "javasuki@hotmail.com", new DateTimeOffset(2014, 06, 22, 10, 58, 27, TimeSpan.FromHours(2)));
    }


git for c#, commit本地,pushserver

标签:test   project   public   rom   net   epo   ide   datetime   oid   

原文地址:http://www.cnblogs.com/blfbuaa/p/6710246.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!