You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 3, 2023. It is now read-only.
Robert N edited this page Oct 25, 2015
·
1 revision
Get a patch file for a single file changed in the working directory (i.e. not committed):
Git
$ git diff myChangedFile.as > myChangedFile.patch
LibGit2Sharp
var patch = repo.Diff.Compare<Patch> (new List<string>() { "myChangedFile.as" });
Complete cut/paste example:
using System;
using System.Collections.Generic;
using LibGit2Sharp;
namespace libgitdiff
{
class MainClass
{
public static void Main (string[] args)
{
var repo = new Repository ("/your/repo/path");
foreach (var item in repo.RetrieveStatus()) {
if (item.State == FileStatus.Modified) {
var patch = repo.Diff.Compare<Patch> (new List<string>() { item.FilePath });
Console.WriteLine ("~~~~ Patch file ~~~~");
Console.WriteLine (patch.Content);
}
}
}
}
}