1

如何使用 GitSharp(用于 .NET 和 Mono 的 Git)通过 SSH 将更改推送到远程服务器?

4

2 回答 2

3

理论上,是的,最新的GitSharp 0.3 版本(2010 年 6 月)包括:

传输代码中的错误修复(通过 http 或ssh推送/获取)

GitSharp README.txt确实有:

对象传输

  • 通过 ssh、git、http 和包获取。
  • 通过 ssh、git 推送。Git# 尚未
    对推送的包进行 deltify,因此它们可能比 C Git 包大很多。

您将在此线程中找到此类推送(通过 ssh)的示例:

Repository repository = new Repository(@"\path\to\my_repos");
repository.Index.Add(@"\path\to\my_file");

Commit commited = repository.Commit("Testing fromGitC#", new Author("Author", "...@aCompany.com"));

if(commited.IsValid) {
    PushCommand pushCommand = new PushCommand {
        RefSpecs = new List<RefSpec> {
           new RefSpec("HEAD", "refs/for/master")
        },
        Force = true,
        Repository = repository
    };
    pushCommand.AddAll();
    pushCommand.Execute();
} 
于 2010-11-09T12:55:14.597 回答
2

GitSharp 基于 JGit 从 Java 到 C# 的手动移植。还有另一个项目是半自动的(目的是添加到 MonoDevelop)

http://foodformonkeys.blogspot.com/2010/10/ngit.html

https://github.com/slluis/ngit

关于NGIT

NGit 是 JGit [1] 到 C# 的一个端口。此端口是使用 Sharpen [2] 半自动生成的,它是一种 Java 到 C# 转换实用程序。

NGit 提供了 JGit 实现的所有功能,包括所有存储库操作原语和传输协议。SSH 支持由项目中包含的 jsch [3] 端口提供。

该项目由 4 个库组成: - NGit:git 库。- NGit.Test:NGit 的单元测试 - NSch:jsch 的端口。- 锐化:上述库所需的一些支持类。

于 2010-11-09T14:11:03.250 回答