[상단]git for c#,commit 로컬,push 서버

1338 단어 gitC#
//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);

            }
        }
    public static class Constants
    {
        public static readonly Signature Signature = new Signature("javasuki", "[email protected]", new DateTimeOffset(2014, 06, 22, 10, 58, 27, TimeSpan.FromHours(2)));
    }

좋은 웹페이지 즐겨찾기