git cat file
Git
$git cat-file {sha}:{filename}
LibGit2Sharp
repo.Head.Tip[{FilePathToContentFrom}].Target as Blob;
using (var content = new StreamReader(blob.GetContentStream(), Encoding.UTF8))
{
commitContent = content.ReadToEnd();
}
From StackOverFlow
Complete example:
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using LibGit2Sharp;
namespace libgitblob
{
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 blob = repo.Head.Tip[item.FilePath].Target as Blob;
string commitContent;
using (var content = new StreamReader(blob.GetContentStream(), Encoding.UTF8))
{
commitContent = content.ReadToEnd();
}
string workingContent;
using (var content = new StreamReader(repo.Info.WorkingDirectory + Path.DirectorySeparatorChar + item.FilePath, Encoding.UTF8))
{
workingContent = content.ReadToEnd();
}
Console.WriteLine ("\n\n~~~~ Original file ~~~~");
Console.WriteLine(commitContent);
Console.WriteLine ("\n\n~~~~ Current file ~~~~");
Console.WriteLine(workingContent);
}
}
}
}
}

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.
