我正在为Web开发实现GIT,我想拥有每个人都推动自动反映其中最新提交的工作副本存储库(因为它在线,团队中的每个人都可以将其视为测试站点)。现在,你需要在有人推送它之后在存储库中运行“git reset --hard HEAD”才能获得最新版本。
答案 0 :(得分: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 Raabe”
中的Git: Post-update hook that runs a script that needs access to all files in the repository所建议的那样