我正在尝试使用PHPseclib来SSH并在远程服务器上运行命令。我想更改目录和命令,如git pull或clone。有没有办法做到这一点?我知道“cd”与exec不兼容。那么任何替代方案呢? 感谢
答案 0 :(得分:2)
您无需更改文件夹,只需将其指定给您的git命令。
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
由于git 1; 8.5(如果你的服务器安装了最新的git版本),你甚至可以使用短版本(detailed here)
git -C /path/to/repo remote add xxx
git -C /path/to/repo pull