假设有一个生产网站,即托管在某个网络托管公司服务器上,并可通过网络公开访问。
现在开发人员想要进行一些代码更改。以下程序是在真实的网络公司中采用的吗?
然后,一旦用户刷新页面,更改将反映在其浏览器上。
以上程序是否正确(我知道它可能过于简化,但我只是想知道这是否是一般流程)?
答案 0 :(得分:1)
做一个主分支进行生产,每次上传都将合并到这个主分支并推送,在prod服务器上做一个拉动。简单的。
答案 1 :(得分:1)
执行此操作的一种方法是使用git hook
。例如,您可以执行以下操作:
在生产服务器上,创建存储库的克隆,将其置于$wvalue
下,然后将/var/git/<repository>
重命名或复制到/var/git/<repositiory>/hooks/post-update.sample
。然后编辑/var/git/<repository>/hooks/post-update
,将其更改为:
/var/git/<repository>/hooks/post-update
确保 !/bin/sh
# move into location of your production folder
cd /var/www/<repository> || exit
unset GIT_DIR
# pull the /var/git/<repository> into production
git pull hub master`
可以正常运行:
/var/git/<repository>/hooks/post-update
然后,您将进入生产的Web根目录并克隆存储库。
chmod +x /var/git/<repository>/hooks/post-update
最后在您的本地环境中添加一个遥控器:
cd /var/www/<repository>/
git clone /var/git/<repository>
cd <repository>
git remote rename origin hub
然后,您可以将本地更改推送到生产服务器存储库,这反过来将触发 git remote add production <user>@<server>:/var/git/<repository>
挂钩,这将检查主服务器到生产文件夹。请注意,您还需要将更改推送到实际的主存储库:
post-update
您应该注意到不处理任何数据库迁移。为了解决这个问题,我会使用 git push staging master
之类的CI
或类似内容。