I am trying to learn Git. Right now i am using LibGit2Sharp
library to play around with my Git repository.
I want to display the current Repository files structure, including the new files that have been added but not yet comitted.
I see that i can get the Tree
of the latest commit i made:
using (var repo = new Repository(repositoryPath))
{
Tree tree = repo.Head.Tip.Tree;
TraverseTree(tree);
}
void TraverseTree(Tree tree)
{
foreach (TreeEntry item in tree.ToList())
{
Console.WriteLine(item.Path);
if (item.TargetType == TreeEntryTargetType.Tree)
{
Tree subTree = (Tree)item.Target;
TraverseTree(subTree);
}
}
}
Is possible to fetch the current Reository structure, including the new files using Git?
I want to display the current Repository files structure, including the new files that have been added but not yet committed.
It looks like you're after something like git status.
This can easily be done with LibGit2Sharp through the repo.RetrieveStatus()
method.
In order to get a broader understanding of the feature and its use cases, I'd advise you to take a look a the StatusFixture test suite.