title: Better alternative to batch file for automatic Git-Pull on windows server
body: <p>I have a set of web servers, and to keep the files up to date on the server, I use a windows scheduled task.  The task calls a batch file which executes a git-pull command.</p>
  
  <p>This seems simple enough, but I use SSH keys to authenticate to the git server.  So far, the only method I have been able to figure out to pass these keys to git is to use <code>pageant.exe</code>.  As a result, my batch file contains the following commands:</p>
  
  <pre><code>"C:\Program Files\TortoiseGit\bin\pageant.exe" "C:\privateKey.ppk"
  set local
  set HOME=c:\
  set GIT_SSH=C:\Program Files\TortoiseGit\bin\TortoisePLink.exe
  cd c:\webserverfiles
  git pull -v --progress origin master
  </code></pre>
  
  <p>This works for the most part; however, a major issue is that pageant runs in the background, and on the first execution of this batch file, the first line hangs indefintely.  To work around this, I manually run the task, kill it, then let it run automatically afterward.  But, if pageant crashes or the server is rebooted, my files no longer synchronize on that server because of the first-line problem (which could be a big problem in a round-robin scenario).</p>
  
  <p>Are there any suggestions as to how to improve this scheme?  I cannot switch to https-based git.</p>