git diff {filename} local.patch
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);
}
}
}
}
}

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
