Reputation: 727
I'm trying to use PHPseclib to SSH and run commands on the remote server. I want to change directory and commands like git pull or clone. Is there a way to do this? I know that "cd" doesn't work well with exec. So any alternatives to this? Thanks
Upvotes: 3
Views: 598
Reputation: 1326706
You don't need to change folder, only to specify it to your git command.
git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo remote add xxx
git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo pull
Since git 1;8.5 (if your server hasd a recent enough git version installed), you even can use the short version (detailed here)
git -C /path/to/repo remote add xxx
git -C /path/to/repo pull
Upvotes: 2