我正在尝试在将代码推送到我的Bitbucket存储库时设置自动部署。我有一个PHP部署脚本,从这篇博客中借鉴了一些内容,但当脚本运行时,它只记录更新自上次提交以来的更改。
举个例子,如果我登录到服务器并输入git pull命令,服务器将使用最新更改进行更新,假设该提交的哈希值为001。但是,如果我进行了多次提交,比如002、003和004,假设我每次提交后都将更改推送到Bitbucket,则我的脚本应该每次都运行。脚本确实运行了,但每次都会保留001的更改。只有当我登录到服务器并输入git pull命令时,服务器才会更新到004。您知道是什么原因导致这种情况吗?
举个例子,如果我登录到服务器并输入git pull命令,服务器将使用最新更改进行更新,假设该提交的哈希值为001。但是,如果我进行了多次提交,比如002、003和004,假设我每次提交后都将更改推送到Bitbucket,则我的脚本应该每次都运行。脚本确实运行了,但每次都会保留001的更改。只有当我登录到服务器并输入git pull命令时,服务器才会更新到004。您知道是什么原因导致这种情况吗?
// Make sure we're in the right directory
exec('cd '.$this->_directory, $output);
$this->log('Changing working directory... '.implode(' ', $output));
// Discard any changes to tracked files since our last deploy
exec('git reset --hard HEAD', $output);
$this->log('Reseting repository... '.implode(' ', $output));
// Update the local repository
exec('git pull '.$this->_remote.' '.$this->_branch, $output);
$this->log('Pulling in changes... '.implode(' ', $output));
// Secure the .git directory
exec('chmod -R og-rx .git');
$this->log('Securing .git directory... ');
if (is_callable($this->post_deploy))
{
call_user_func($this->post_deploy, $this->_data);
}
$this->log('Deployment successful.');
git submodule update
。 - halfer