简体   繁体   English

我可以将git储存库中的所有文件“推送”到ftp服务器(实时生产)吗?

[英]Can I 'push' all the files in my git repository to my ftp server (live production)?

I just started (barely) to somewhat understand and use git. 我刚刚(勉强)开始对git有所了解和使用。 I'm using github and cloud9 IDE. 我正在使用github和cloud9 IDE。

I figured out how to save (commit and then push ?) files to the github repository... 我想出了如何将文件保存(提交然后推送?)到github存储库中...

question : 问题

Is there a command that will upload (and overwrite) files from my git to my ftp server where my website is hosted?

I've checked this question , but I'm not sure I want a .git on my server (unless I can still run my site off it). 我已经检查了这个问题 ,但是我不确定我的服务器上是否需要.git(除非我仍然可以在其上运行我的网站)。

I've also checked this question , but I'm not sure I can install anything on my server. 我也检查了这个问题 ,但是不确定我可以在服务器上安装任何东西。

Is this not as simple as I thought it would be? 这不是我想的那么简单吗?

Any help is much appreciated. 任何帮助深表感谢。

Git is not an FTP client. Git不是FTP客户端。 But you could create a post-commit hook to do this. 但是您可以创建一个提交后钩子来执行此操作。 A git hook is a shell script which is executed with certain actions. git hook是一个shell脚本,它通过某些动作执行。 You could use this to upload all of your source files to your FTP server when you do a commit. 进行提交时,可以使用此选项将所有源文件上传到FTP服务器。 For more information about hooks, see: 有关钩子的更多信息,请参见:

http://www.kernel.org/pub/software/scm/git/docs/githooks.html http://www.kernel.org/pub/software/scm/git/docs/githooks.html

If you are working on the commandline - use lftp to ftp your files to your host. 如果使用命令行-使用lftp将文件ftp传送到主机。 lftp is highly scriptable and will allow you to add it to a post-commit hook if you so desire. lftp具有高度的脚本编写性,如果需要,可以将其添加到提交后的钩子中。

If you are using a gui - you can try filezilla or any number of other ftp clients to move your files to your server. 如果您使用的是gui,则可以尝试使用filezilla或任意数量的其他ftp客户端将文件移动到服务器。

If this is a project that you want other to work on in the future, you can consider learning capistrano for automatic deployments and ease of releases. 如果这是您希望其他人将来从事的项目,则可以考虑学习capistrano,以实现自动部署和易于发布。

As I mentioned in this answer , PHPloy is a great tool for sending your git changes to remote servers over FTP (you don't have to install anything on the server, which is great if you're on a shared web host). 就像我在这个答案中提到的那样, PHPloy是一个很棒的工具,可以通过FTP将git更改发送到远程服务器(您不必在服务器上安装任何东西 ,如果您在共享的Web主机上,那就太好了)。 It works from the command line and is written in cross-platform PHP (and even detects changes in submodules). 它可以从命令行运行,并使用跨平台的PHP编写(甚至可以检测子模块中的更改)。

https://github.com/banago/PHPloy https://github.com/banago/PHPloy

From your local development machine, you just type... 在本地开发机器上,您只需输入...

git commit ...
phploy -s stagingServer
phploy -s productionServer

Done! 做完了!

(Disclaimer: after using it for a while I've now contributed some code patches and improvements, making it Windows-compatible.) (免责声明:使用一段时间后,我现在做出了一些代码补丁和改进,使其与Windows兼容。)

Whether using OSX, you can consider this GUI-based pretty convenient workflow (I also use for some WordPress stuff): http://eppz.eu/blog/push-git-to-ftp/ 无论使用OSX,您都可以考虑使用这种基于GUI的非常方便的工作流程(我也使用了一些WordPress的东西): http : //eppz.eu/blog/push-git-to-ftp/

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM