Context: I am building an automated build script which will run on a Windows server box (necessary because our development software package is windows only). My client box is also Windows. It should execute a number of steps, one of which is to login to github, discard all local changes (just in case; there really shouldn't be any local changes), fetch and merge.
Restrictions:
1) I should be able to run one batch file (or other script file, as long as it runs on a windows box)
2) I cannot walk over to the box and input my password for SSH everytime. It should work automatically.
Problem: I cannot get Git and SSH to work nicely with my Windows batch file.
My First Attempt:
:: set repo folder
CD %2
:: check status
CALL git status
ECHO.
:: discard all changes
ECHO ~ discard all changes
ECHO.
CALL git reset --hard
CALL git clean -f -d
ECHO.
:: switch branch
ECHO ~ checkout branch %4
ECHO.
CALL git checkout %4
ECHO.
:: get any changes from server
ECHO ~ fetch %3
ECHO.
CALL git fetch %3
ECHO.
:: merge changes into current branch
ECHO ~ merge %3/%4
ECHO.
CALL git merge %3/%4
ECHO.
The parameter %2 is the windows file location, %3 is the github HTTPS url, %4 is the branch name.
This works, but uses HTTPS, which means entering my username and password manually.
So I tried doing it in SSH (via bash), using the commands:
eval `ssh-agent`
ssh-add /z/id_rsa
like so from batch:
CD C:\Program Files (x86)\Git\bin\
sh.exe --login -i -c "eval `ssh-agent` && ssh-add /z/id_rsa && exit"
However, SSH also requires me to enter the key passphrase every time I use this command.
How can I, either A) keep the SSH login information live between batch/bash scripts or B) enter the passphrase programmatically?