Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I launch the sequence of git commands from java application?

Tags:

java

git

I need to add the file to the repository and then commit it from my java project. I use

Runtime.getRuntime().exec("C:\\Program Files (x86)\\Git\\bin\\sh.exe");

to start git but what should I do next?

like image 869
cadmy Avatar asked Feb 09 '26 18:02

cadmy


1 Answers

Instead of running the command line tool directly from your Java application, consider using Git APIs for Java, such as JavaGit. The cookbook has examples that you can follow.

like image 152
Tania Ang Avatar answered Feb 12 '26 16:02

Tania Ang