简体   繁体   English

将项目从本地复制到服务器B(不是git服务器)后,将git push到服务器A(每个都通过ssh)

[英]Copy project from local to server B (not a git server) after git push to server A (each via ssh)

I have a git project on my Mac. 我的Mac上有一个git项目。 And i push my changes via ssh to a git-server ("Server B") (github or gitbucket or own should be irrelevant here). 我通过ssh将更改推送到git-server(“服务器B”)(github或gitbucket或own应该无关紧要)。

And then there is the hosted webserver ("Server A") which shows the state of developement to the customers. 然后是托管的Web服务器(“服务器A”),向客户显示开发状态。 From time to time i login to my webserver via ssh and type git pull to update the project before i tell the customer that there is a new version. 我不时通过ssh登录到我的Web服务器,并键入git pull来更新项目,然后再告诉客户有新版本。

Is there a way to automate that? 有没有办法使它自动化? Is it possible to set something up, that always send the files to "Server A" with some kind of copy command after i do a git push on my local computer? 是否可以进行设置,在我对本地计算机执行git push之后,始终使用某种复制命令将文件发送到“服务器A”?

You can setup a git hook , post-commit , on your local computer to ssh and pull on the Server A each time you commit something. 您可以在本地计算机上设置git hookpost-commit ,以在每次提交内容时ssh并拉上ServerA。

There is no client side hook for pushing but if you don't want a hook to run each time you commit, you could simply alias a command like git push && bash update_SERVER_A.sh . 没有用于推送的客户端挂钩,但是如果您不想在每次提交时都运行挂钩,则可以简单地为 git push && bash update_SERVER_A.sh类的命令添加别名。

Apparently a pre-push hook is being added in 1.8.2 , so even better ;) 显然, 在1.8.2中添加了一个pre-push钩子 ,所以更好;)

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

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