0

I have written a batch file for some git commands, here is the code

@echo off
setlocal

set /p branch_name=Enter the branch name: 

rem Checkout a different branch
git checkout branch2

rem Delete the asked branch
git branch -D %branch_name%

git fetch

rem Checkout the asked branch again
git checkout %branch_name%

endlocal

now after git fetch it asks for the passphrase for ssh key , that i want to fill automatically from the batch file

i tried with echo like this

echo passphrase | git fetch

but it did not work

any help on this?

And one more thing if on start it can ask do you want to use current branch then y/N. if y then no need to ask enter branch name otherwise ask the branch name to use?

Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
  • 2
    Is it a valid option to use an SSH key without a passphrase? That way, git will not prompt. – Torge Rosendahl Aug 25 '23 at 07:24
  • 1
    Run `ssh-agent` and `ssh-add` the key: https://stackoverflow.com/a/55153372/7976758 See also https://stackoverflow.com/search?q=%5Bssh-agent%5D+windows – phd Aug 25 '23 at 10:49

0 Answers0