涉及远程结账的预推和后推钩 [英] Pre-push and post-push hooks involving remote checkout
问题描述
我使用 git flow $ c $
- master
- 开发 >
- 功能/一个
- 功能/两个
- 发布/一个 release / two
- etc
简化的工作流程如下:
- 对
开发进行更改
- 服务器
- 结帐至
主人
- 合并
主人
with development` - 将
master
移至服务器中
我想要实现的是,当我将 master
分支推送到活服务器时,我应该能够在访问网站时立即看到更改通过网址。
问题在于我无法真正推送 master
,因为它是在实时检出SE rver。
我可以编写一个pre-push hook来远程执行 dummy
分支的结帐操作,并且一个推后挂钩,它将结账返回到 master
?关键是这些钩子涉及在远程执行git命令,我不知道如何做到这一点。
非常感谢任何示例!
您应该向 bare repo 。 然后, post-receive
hook 可以在您的实时服务器上检出裸露的rpeo。
cd /path/to/bare/repo.git
GIT_WORK_TREE = / path / to / live / server git checkout -f
I have a remote repository for a website which I am developing on my local machine.
I use git flow
for neat branching model, so my branches are:
- master
- develop
- feature/one
- feature/two
- release/one
- release/two
- etc
The simplified work flow is as follows:
- make changes in
develop
- push develop to backup server
- checkout to
master
- merge
master
with develop` - push
master
to live server
What I want to achieve, is that when I push master
branch to live server, I should be able to instantly see changes when accessing website by URL.
The problem is that I can't really push master
, because it is checked out on live server.
Can I write a pre-push hook which will do a checkout to dummy
branch on remote, and a post-push hook which will do a checkout back to master
? The point is that these hooks involves execution of git commands on remote and I'm not sure how to do this.
Would appreciate any examples very much!
You should push to master on a bare repo.
Then a post-receive
hook can checkout that bare rpeo on your live server.
cd /path/to/bare/repo.git
GIT_WORK_TREE=/path/to/live/server git checkout -f
这篇关于涉及远程结账的预推和后推钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!