外部外壳来部署一个git文件夹 [英] External shell to deploy a git folder

查看:177
本文介绍了外部外壳来部署一个git文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git下有myapp文件夹。使用几个分支(master,dev,test,prod,...)。
我想制作一个外部shell脚本(不在myapp文件夹中的脚本)将给定分支部署到Web服务器。

I have "myapp" folder under git. Several branches are used (master, dev, test, prod, ...). I'd like to make an external shell script (script that is not in the "myapp" folder) to deploy a given branch to a web server.

如何从外部脚本中选择专用分支?

How can I select a dedicated branch from an external script?

这个想法是使用类似于:

The idea is to use something like:

cp -r myapp@dev my_we_folder_path 
# myapp@dev beeing the dev branch of myapp folder

显然, myapp @ dev不是一个正确的git符号,但在git中是否有相当的东西?

Obviously, myapp@dev is not a correct git notation, but is there something equivalent in git?

推荐答案

正如SO问题 git post-receive hook来更新多个服务器,通常的方式是通过类似于这一个

As illustrated by the SO question "git post-receive hook to update multiple servers", the usual way of implementing that feature is through a post-receive hook similar to this one.

这个想法是,在新的提交中,将你的git repo归档并提取它/ rsync它在哪里您需要部署它。

正如 git-ar chive vs. cp ,这比仅用于所有git repo的更好。

这与在部署平台上没有任何VCS功能的做法一致,并且只保留您需要在生产环境中运行您的程序。

The idea is to, on new commits, make an archive of your git repo and extract it/rsync it where you need to deploy it.
As mentioned in "git-archive vs. cp", this is better than just cp an all git repo.
And this is consistent with the practice of not having any VCS feature on the deployment platform, and keep only what you need to run your program in a production environment.

这篇关于外部外壳来部署一个git文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆