Git: command not found via bash

bashgit

I'm quite new to bash, so I'm sorry if I'm asking something silly. Long story short, I'm trying to run the following bash script:

#!/bin/sh

ACTION="init" # init or push
USERNAME="username"
PASSWORD="password"
HOST="host.com"
PATH="WebSite/app"
DRYRUN="-D" # use -D for dry-run

cd ./htdocs/app/

git checkout master # switch to master
git push # push to origin
git ftp $ACTION --user $USERNAME --passwd $PASSWORD $DRYRUN ftp://$HOST/$PATH

but when I do, I get the following error:

deploy.sh: line 12: git: command not found
deploy.sh: line 13: git: command not found
deploy.sh: line 14: git: command not found

If I were to follow the steps in the script directly myself, it works as intended, but not when running via bash.

I think it might have something to do with git not being in my $PATH, which looks like this: /home/daniel/.rvm/gems/ruby-1.9.3-p286/bin:/home/daniel/.rvm/gems/ruby-1.9.3-p286@global/bin:/home/daniel/.rvm/rubies/ruby-1.9.3-p286/bin:/home/daniel/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/daniel/.rvm/bin but if that is the case, then I'm not sure how to add it.

Can someone help? Thank you 🙂

Best Answer

You've overwritten your PATH in your script. Don't overwrite it, just append "WebSite/app" to your PATH:

PATH=$PATH:"WebSite/app"

Related Question