Git 推入生产 (FTP)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2950107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git Push into Production (FTP)
提问by Roch
I would like to know if there is an easy way to push a GIT repository into production (on a FTP server) ? Thanks
我想知道是否有一种简单的方法可以将 GIT 存储库推入生产环境(在 FTP 服务器上)?谢谢
回答by Tim Henigan
Some tools recently added to the Git wiki:
最近添加到Git wiki 的一些工具:
git-ftpby René Moser is a simple shell script for doing FTP the Git way. Use git-ftp.sh to upload only the Git tracked files to a FTP server, which have changed since the last upload. This saves time and bandwith. Even if you play with different branches, git-ftp.sh knows which files are different. No ordinary FTP client can do that.
git-ftpby Edward Z. Yang is a simple script written in python for uploading files in a Git repository via FTP, only transferring new files and removing old files.
René Moser 的git-ftp是一个简单的 shell 脚本,用于以 Git 方式执行 FTP。使用 git-ftp.sh 仅将 Git 跟踪的文件上传到 FTP 服务器,这些文件自上次上传后已更改。这节省了时间和带宽。即使你玩不同的分支,git-ftp.sh 也知道哪些文件是不同的。没有普通的 FTP 客户端可以做到这一点。
Edward Z. Yang 的git-ftp是一个用 python 编写的简单脚本,用于通过 FTP 上传 Git 存储库中的文件,仅传输新文件并删除旧文件。
回答by Geri Borbás
If you prefer GUI, use SourceTree, you can easily setup a Custom Action that uses git-ftp mentioned above. A brief description on setup (for Mac) at Push a Git repository to an FTP
如果您更喜欢 GUI,请使用 SourceTree,您可以轻松设置使用上述 git-ftp 的自定义操作。将Git 存储库推送到 FTP 中有关设置(适用于 Mac)的简要说明
回答by Simon East
I've found PHPloya great tool for sending your Git commits to remote servers over FTP. It works from the command-line and is written in PHP (and even detects changes in submodules).
我发现PHPloy是一个很棒的工具,可以通过 FTP 将您的 Git 提交发送到远程服务器。它从命令行工作并用 PHP 编写(甚至检测子模块中的更改)。
https://github.com/banago/PHPloy?
https://github.com/banago/PHPloy?
git commit ...
phploy -s staging
phploy -s production
Done!
完毕!
(Disclaimer: after using it for a while I've now contributed some code patches and improvements, making it Windows-compatible.)
(免责声明:使用它一段时间后,我现在贡献了一些代码补丁和改进,使其与 Windows 兼容。)
回答by Rob Sawyer
If you're on a mac and have Transmit, I'd recommend the following git-tranmit script (https://gist.github.com/379750). It uses DockSend to send only the last updated files. If you're not familiar with DockSend, check out http://www.panic.com/blog/2010/11/15-secrets-of-transmit/.
如果您使用的是 mac 并且有 Transmit,我建议您使用以下 git-tranmit 脚本 ( https://gist.github.com/379750)。它使用 DockSend 只发送最后更新的文件。如果您不熟悉 DockSend,请查看http://www.panic.com/blog/2010/11/15-secrets-of-transmit/。
Setup:
设置:
- cp git-transit /usr/sbin/.
- cd /usr/sbin
- chmod +x git-transmit
- Setup drop send for your live app
- Run git-transmit in your git repository.
- cp git-transit /usr/sbin/.
- cd /usr/sbin
- chmod +x git-transmit
- 为您的实时应用设置直接发送
- 在您的 git 存储库中运行 git-transmit。
回答by sblundy
That's not what git is for, strictly speaking. However, if your source is something that doesn't need compiling or processing, say a website consisting entirelyof html and javascript files and the like, you could have a clone of the repo on your webserver and use git pull
from the server to keep it up-to-date. Note, I would config your webserver to hide the git directory and such. And that's just the beginning of the security concerns.
严格来说,这不是 git 的用途。但是,如果您的源代码不需要编译或处理,例如一个完全由 html 和 javascript 文件等组成的网站,您可以在您的网络服务器上克隆一个 repo,并git pull
从服务器使用它来保持它-迄今为止。请注意,我会配置您的网络服务器以隐藏 git 目录等。而这只是安全问题的开始。
If you have any sort of compiling or processing, you should start looking at Ant, Maven, BuildR, SBT, etc.
回答by joelmez4
You could use Deployhq.comit works like a charm, the only thing you need to do is to set up your repository and FTP account.
你可以使用Deployhq.com它就像一个魅力,你唯一需要做的就是设置你的存储库和 FTP 帐户。
They currently the following version control systems:
他们目前有以下版本控制系统:
Git, Subversion, Mercurial.
Git、Subversion、Mercurial。
With repository hosted
托管存储库
- GitHub
- Bitbucket
- GitLab
- Codebase
- GitHub
- 比特桶
- GitLab
- 代码库
回答by Marco Antonio
This is a script in PHP to upload almost automatically the git-diff to a FTP server:
这是一个 PHP 脚本,用于将 git-diff 几乎自动上传到 FTP 服务器:
回答by Dave Thompson
Free for one project and it works very very well.
一个项目免费,效果非常好。
回答by dodgy_coder
There's a Ruby script here - Ruby git-deploy via FTP or SSHwhich uploads only the changed files in the git repo via FTP or SSH.
这里有一个 Ruby 脚本 - Ruby git-deploy via FTP 或 SSH,它仅通过 FTP 或 SSH上传 git repo 中已更改的文件。
As mentioned in another answer, here is the Python git-ftp.py scriptwhich does a similar thing.
正如另一个答案中提到的,这里是Python git-ftp.py 脚本,它执行类似的操作。
And here is the shell script version of git-ftp.
这是git-ftp的 shell 脚本版本。
There is also a Ruby gem project called git-deploywhich lets you setup a custom deploy via a git remote using the git push
command, in the same way as the Heroku and Azure services. For this one you may need to write custom methods to deploy via FTP and I think it assumes you have SSH access to your production server.
还有一个名为git-deploy的 Ruby gem 项目,它允许您使用git push
命令通过 git 远程设置自定义部署,与 Heroku 和 Azure 服务的方式相同。对于这个,您可能需要编写自定义方法以通过 FTP 进行部署,我认为它假设您可以通过 SSH 访问您的生产服务器。
回答by Justin Ethier
If you are putting code into production, I recommend using an "installer" such as an RPM package to install your code. That way it will be version stamped and you will be able to leverage the installer package to support updates to the production code. Git is not really designed to support production installations, it is intended to track changes to the code itself.
如果您要将代码投入生产,我建议您使用“安装程序”(例如 RPM 包)来安装您的代码。这样,它将被标记版本,您将能够利用安装程序包来支持对生产代码的更新。Git 并非真正旨在支持生产安装,它旨在跟踪代码本身的更改。
In any event, with an .RPM (or EXE or whatever) built, you can just FTP it to the production system and install it like any other package.
在任何情况下,通过构建 .RPM(或 EXE 或其他),您只需将其 FTP 到生产系统并像安装任何其他软件包一样安装它。