How to run git commands from NodeJS


I want to run few git commands from NodeJS, how can I do that?

1 Answer

4 years ago by

Simplest way to run git commands in NodeJS is using the default child_process. Following code shows how to run git pull command in NodeJS

const { exec } = require('child_process');

exec('git pull', (err, stdout, stderr) => {
 // handle err, stdout & stderr
});
4 years ago by Karthik Divi