Run Git Commands from Java Applications

Tuesday, January 30, 2018

A few days ago I came across the following question: "how to execute git commands from a java application". After a little research I found a library called JGit which fulfilled my expectations. In this post I will explain how to use this library to execute the basic commands.   To import the library, add the following dependency to your pom file: <dependency> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit</artifactId> <version>4.10.0.201712302008-r</version> </dependency>   Then you will be able to import and use the JGit classes import org.eclipse.jgit.*;   To clone a repository you can use the following method: public...
no comments