title: How to execute git commands from bash script?
body: <p>I have the following bash script to start the ssh-agent, add my keys and do a git pull on a repo. The agent is started, the key is added but the git pull doesn't execute...at least nothing is echo'd to the terminal. The git command works if I type it into the terminal...is there something I need to do within my bash script to make it work?</p>
  
  <pre><code>#!/bin/bash
  
  # if we can't find an agent, start one, and restart the script.
  if [ -z "$SSH_AUTH_SOCK" ] ; then
    exec ssh-agent bash -c "ssh-add ; $0"
    exit
  fi
  
  exec ssh-add ~/.ssh/mykey
  git --git-dir=/var/www/node/myapp/.git pull origin master
  </code></pre>
  
  <hr>
  
  <p>When I add -x to #!/bin/bash this is the terminal output</p>
  
  <pre><code>+ '[' -z '' ']'
  + exec ssh-agent bash -c 'ssh-add ; ./startgit.sh'
  + '[' -z /tmp/ssh-&lt;redacted&gt;/agent.1733 ']'
  + exec ssh-add /home/ec2-user/.ssh/mykey
  Identity added: /home/ec2-user/.ssh/mykey (/home/ec2-user/.ssh/mykey)
  </code></pre>