public static void OpenRepo() { Git repository = Git.Open(@"C:\Git\NGit"); // Fetch changes without merging them NGit.Transport.FetchResult fetch = repository.Fetch().Call(); // Pull changes (will automatically merge/commit them) PullResult pull = repository.Pull().Call(); // Get the current branch status Status status = repository.Status().Call(); // The IsClean() method is helpful to check if any changes // have been detected in the working copy. I recommend using it, // as NGit will happily make a commit with no actual file changes. bool isClean = status.IsClean(); // You can also access other collections related to the status System.Collections.Generic.ICollection<string> added = status.GetAdded(); System.Collections.Generic.ICollection<string> changed = status.GetChanged(); System.Collections.Generic.ICollection<string> removed = status.GetRemoved(); // Clean our working copy System.Collections.Generic.ICollection<string> clean = repository.Clean().Call(); // Add all files to the stage (you could also be more specific) NGit.Dircache.DirCache add = repository.Add().AddFilepattern(".").Call(); // Remove files from the stage NGit.Dircache.DirCache remove = repository.Rm().AddFilepattern(".gitignore").Call(); }
} // End Function HasChanges public virtual void UnleashHeavok(string path) { NGit.Api.Git repository = NGit.Api.Git.Open(path); // Get the current branch status NGit.Api.Status status = repository.Status().Call(); // You can also access other collections related to the status System.Collections.Generic.ICollection <string> added = status.GetAdded(); System.Collections.Generic.ICollection <string> changed = status.GetChanged(); System.Collections.Generic.ICollection <string> removed = status.GetRemoved(); // Clean our working copy System.Collections.Generic.ICollection <string> clean = repository.Clean().Call(); // Add all files to the stage (you could also be more specific) NGit.Dircache.DirCache add = repository.Add() .AddFilepattern(".") .Call(); // Remove files from the stage NGit.Dircache.DirCache remove = repository.Rm() .AddFilepattern(".gitignore") .Call(); CloseRepository(repository); } // End Sub UnleashHeavok