-1

I'm using NodeJS to execute multiple git command lines. Updating submodules, pulling some projects, etc. Everything works but I have an inconvenient issue. When I perform two command lines, like this

const exec = util.promisify(require('child_process').exec);

await exec('cd my/project/path && git pull');
await exec('cd my/other/project/path && git pull');

I'm forced to enter my SSH key passphrase two times. I tried await exec('cd my/project/path && git pull && cd my/other/project/path && git pull'); but the result is the same (passphrase asked two times).

Is this possible to use the ssh-agent to keep the passphrase between the two command lines? Or any other solution?

Vy Do
  • 46,709
  • 59
  • 215
  • 313
Magus
  • 14,796
  • 3
  • 36
  • 51

1 Answers1

0

A solution for at least linux environments:

const exec = util.promisify(require('child_process').exec);

await exec('ssh-add');
await exec('cd my/project/path && git pull');
await exec('cd my/other/project/path && git pull');
Magus
  • 14,796
  • 3
  • 36
  • 51