Reputation: 5959
How can GitSharp (Git for .NET and Mono) be used to PUSH changes changes to a remote server over SSH?
Upvotes: 1
Views: 2428
Reputation: 5959
GitSharp is based upon a manual port of JGit from Java to C#. There is another project does this semi-automatically (with the purpose of being added to MonoDevelop)
http://foodformonkeys.blogspot.com/2010/10/ngit.html
https://github.com/slluis/ngit
ABOUT NGIT
NGit is a port of JGit [1] to C#. This port is generated semi-automatically using Sharpen [2], a Java-to-C# conversion utility.
NGit provides all functionality implemented by JGit, including all repository manipulation primitives and transport protocols. SSH support is provided by a port of jsch [3], included in the project.
The project is composed by 4 libraries: - NGit: The git library. - NGit.Test: Unit tests for NGit - NSch: The port of jsch. - Sharpen: Some support classes required by the above libraries.
Upvotes: 2
Reputation: 1325137
In theory, yes, the latest GitSharp 0.3 release (June 2010) includes:
bug fixes in the transport code (pushing / fetching via http or ssh)
The GitSharp README.txt does have:
Object transport
- Fetch via ssh, git, http and bundles.
- Push via ssh, git. Git# does not yet deltify
the pushed packs so they may be a lot larger than C Git packs.
You will find an example of such a push (over ssh) in this thread:
Repository repository = new Repository(@"\path\to\my_repos");
repository.Index.Add(@"\path\to\my_file");
Commit commited = repository.Commit("Testing fromGitC#", new Author("Author", "[email protected]"));
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();
}
Upvotes: 3