问题描述
我现在正在尝试使用git,并试图创建一个工作流程,以便在服务器上推送到裸露的远程回购站,并根据不同的分支更新2个不同的站点。
接收到的钩子是:
#!/ bin / sh
GIT_WORK_TREE = / www / development / git checkout -f master
GIT_WORK_TREE = / www / production / git checkout -f production
基于,但只做了一些修改。
不幸的是,在测试它时,将一个新的测试文件提交到任何分支将被推送并成功更新web根目录,但是为了删除相同的测试文件,web root仍然保留已删除文件的副本。
有谁知道我如何获得post-receive hook来强制删除?
我最终做了
#!/ bin / sh
GIT_WORK_TREE = / www / development / git checkout -f master
GIT_WORK_TREE = / www / development / git clean -fdx
GIT_WORK_TREE = / www / production / git checkout -f production
GIT_WORK_TREE = / www / production / git clean -fdx
基于@Koraktor的回答。
I'm trying out git at the moment, and am trying to create a workflow so that a push to a bare remote repo on the server will update 2 different sites based on different branches.
The post-receive hook is:
#!/bin/sh
GIT_WORK_TREE=/www/development/ git checkout -f master
GIT_WORK_TREE=/www/production/ git checkout -f production
based on https://stackoverflow.com/a/3838804/1097483 but with a few modifications.
Unfortunately while testing it, commiting a new test file to any of the branches will be pushed and successfully update the web root, but for deleting the same test file, the web root still retains a copy of the deleted file.
Does anyone know how I can get the post-receive hook to force a delete?
I ended up doing
#!/bin/sh
GIT_WORK_TREE=/www/development/ git checkout -f master
GIT_WORK_TREE=/www/development/ git clean -fdx
GIT_WORK_TREE=/www/production/ git checkout -f production
GIT_WORK_TREE=/www/production/ git clean -fdx
based off @Koraktor 's answer.
这篇关于git post-receive hook不会删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!