Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java git client using jgit

I am having some difficulties with a git client written in java. I am using the jGit library to connect through ssh on the git server. The problem is that i don't know how to specify the path to the private key and the passphrase for it. I couldn't find any examples in the jGit documentation about what functions i need to call. From what i read the jGit library is using JSch to connect to the server using ssh and JSch supports private keys and passphrases. Does anyone have any experience with this or has some working code?

Thank you

like image 419
azertys Avatar asked Oct 31 '11 08:10

azertys


People also ask

Does Eclipse use JGit?

JGit is a relatively full-featured implementation of Git written in Java and is widely used in the Java community. The JGit project is under the Eclipse umbrella, and its home can be found at JGit.

What is org eclipse JGit?

Eclipse JGit™ is a pure Java implementation of the Git version control system. Git is a distributed SCM, which means every developer has a full copy of all history of every revision of the code, making queries against the history very fast and versatile.

How do I put Java code on github?

2.1 Choose the repository where you want to add the code. 2.2 Click on Add File and then click on the Create new file option. 2.4 Make sure to add the extension of the file, for example, “.

Does Git support Java?

If you want to use Git from within a Java program, there is a fully featured Git library called JGit. JGit is a relatively full-featured implementation of Git written natively in Java, and is widely used in the Java community.


1 Answers

I didn't ever use jGit, but from looking at the Javadocs (which are seemingly not online browsable, but can be downloaded) you need to configure a SshSessionFactory (i.e. create a subclass of JSchConfigSessionFactory, and override its configure method).

The JSch object supports private keys with its addIdentity methods, and the passphrases can be given with UserInfo objects to each individual JSch Session.

(Disclaimer: The JSch Javadoc was written by me.)

like image 116
Paŭlo Ebermann Avatar answered Oct 10 '22 16:10

Paŭlo Ebermann