Context: I create an automatic build script that will run on a Windows server (required, because our development software package is only windows). My client box is also Windows. He has to follow several steps, one of which is to log into github, discard all local changes (just in case, there really shouldn't be any local changes), fetch and merge.
Limitations: 1) I must be able to run one batch file (or another script file if it works in the window window) 2) I can not go to the box and enter the password for SSH each time. It should work automatically.
Problem: I cannot get Git and SSH to work 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% 2 parameter is the location of the Windows file,% 3 is the github https URL,% 4 is the branch name.
This works, but uses HTTPS, which means manually entering my username and password.
So I tried to do this in SSH (via bash) using the commands:
eval `ssh-agent` ssh-add /z/id_rsa
for example, from a 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 a passphrase every time I use this command.
How can I either A) save real-time SSH login information between batch / bash scripts or B) programmatically enter a program phrase?