2010-06-03 79 views
1

我正在爲web developemnt實施GIT,並且我希望每個人推送的工作副本存儲庫都會自動反映最新的提交(因爲它適用於所有人在團隊中看到作爲測試網站)。現在,你必須在存儲庫上運行「git reset --hard HEAD」,然後有人推送它以保持最新狀態。當更改推送到目標回購時更新工作

回答

1

其中之一,你通常don't push to a non-bare repository,正是因爲你可以在工作目錄和索引之間以非連貫的狀態過於簡單地結束。

warning: updating the currently checked out branch; this may cause confusion, 
as the index and working tree do not reflect changes that are now in HEAD. 

但由於你的情況,你想利用現有的「活」回購的優勢,你可以設置一個post-receive hook

#!/bin/sh 
export GIT_DIR= 
cd .. 
echo "Resetting working tree..." 
git reset --hard 
echo "Finished resetting working tree." 

,如通過在Frerich RaabeGit: Post-update hook that runs a script that needs access to all files in the repository

建議