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
Asked
Active
Viewed 571 times
3
-
You could use the interactive mode. eg. $ssh->read() / $ssh->write() – neubert Mar 12 '14 at 22:57
1 Answers
2
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
-
Am trying to use the git submodule update command which apparently doesn't seem to work with --git-dir. Any other alternatives? Thanks! – Ananth Ravi Mar 08 '14 at 20:42
-
@AnanthakrishnanRavi then the `-C` option should work. You need to be at the root folder of the parent repo (the one declaring the submodules, and including the submodule folders) – VonC Mar 08 '14 at 20:47