GitSharp.NET的Git开发包

联合创作 · 2023-10-01 11:59

GitSharp 是 .NET 框架和 MONO 实现的 Git,旨在完全兼容 Git,也可作为轻量级的开发库为那些需要 Git 特性的应用以及访问 Git 资料库。

示例代码:

//Opening an existing git repository
repo = new Repository("path/to/repo");

// Now suppose you have created some new files and want to commit them
repo.Index.Add("README", "License.txt");
Commit commit = repo.Commit("My first commit with gitsharp", new Author("henon", "meinrad.recheis@gmail.com"));

// Easy, isn't it? Now let's have a look at the changes of this commit:
foreach (Change change in commit.Changes)
Console.WriteLine(change.Name + " " + change.ChangeType);

//Get the staged changes from the index
repo.Status.Added.Contains("README");

//Access and manipulate the configuration
repo.Config["core.autocrlf"] = "false";

浏览 8
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报