Created
September 4, 2013 17:06
Revisions
-
mm201 created this gist
Sep 4, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ using System; using System.IO; using LibGit2Sharp; namespace PushTestcase { class Program { static void Main(string[] args) { String wd = Directory.GetCurrentDirectory(); String path = wd + "\\test-repo"; Directory.CreateDirectory(path); Repository.Init(path); Console.WriteLine("Initialized test-repo"); StreamWriter sw = File.CreateText(path + "\\test.txt"); sw.Write("This is a test document which will be committed."); Console.WriteLine("Wrote file."); Repository repo = new Repository(path); repo.Index.Stage("test.txt"); Console.WriteLine("Staged file."); repo.Commit("Test commit."); Console.WriteLine("Committed."); repo.Dispose(); repo = null; String clone_path = wd + "\\clone-repo"; Directory.CreateDirectory(clone_path); Repository.Clone(path, clone_path); Console.WriteLine("Cloned repository."); repo = new Repository(path); repo.Branches.Add("otherBranch", repo.Head.Tip); Console.WriteLine("Created secondary branch."); repo.Branches["otherBranch"].Checkout(); // checkout a different branch so we can push master Console.WriteLine("Checked out secondary branch."); repo.Dispose(); repo = null; Repository clone = new Repository(clone_path); clone.Network.Push(clone.Head); Console.WriteLine("Pushed."); clone.Dispose(); clone = null; } } }