【问题标题】:Update working on target repo when changes are pushed to it将更改推送到目标存储库时更新其工作
【发布时间】:2010-06-03 19:52:59
【问题描述】:

我正在为 Web 开发实现 GIT,并且我希望拥有每个人都推送的工作副本存储库,以自动反映其中的最新提交(因为它是在线的,团队中的每个人都可以将其视为测试站点)。现在,您必须在有人推送到存储库后在存储库上运行“git reset --hard HEAD”才能保持最新。

【问题讨论】:

    标签: git


    【解决方案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."
    

    ,正如“Git: Post-update hook that runs a script that needs access to all files in the repository”中的Frerich Raabe 所建议的那样

    【讨论】:

      猜你喜欢
      • 2016-02-21
      • 2016-03-20
      • 2016-06-27
      • 2018-04-19
      • 1970-01-01
      • 2013-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多