Git for c #, commit local, push Server

Source: Internet
Author: User

// OK private static void push () {string wkDir = @ "E: \ DotNet2010 \ unit project \ Git. client \ lib2Test \ leleapplication1 \ bin \ Debug \ D2Git \. git "; using (var repo = new Repository (wkDir) {// at this time, two files, one.txtand two.txt, string fname =" one.txt "; repo, must exist. 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)));    }


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.