當我將git推送到我的bitbucket存儲庫時,我正在嘗試設置自動部署。我有一個php部署腳本,我利用了this blog,但是當腳本運行時,它會記錄它只是從以前的提交中更新。使用Git,Bitbucket和PHP自動部署
這裏是一個例子。假設我登錄到我的服務器並輸入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 2013-04-11 14:26:15
我真的不知道子模塊是什麼。我剛開始使用bitbucket和git。 – 2013-04-11 14:30:22
子模塊是存儲庫中指向標記的存儲庫。我建議儘可能不要使用它。如果您有多個使用相同插件/庫的內部應用程序,則可能會出現這種情況。他們爲此發明了作曲者;) – 2013-04-11 14:43:28