Home  >  Q&A  >  body text

github - git把本地文件推送至linux服务器网站根目录?

正在学写网站,js cs html写好之后每次用ssh推送到服务器要好长的代码,怎么把本地的网站文件用git命令推送到远程服务器(ip 1.1.1.1)的网站根目录/home/www下(网页文件的github库和本地库都已建好)。
OS:
本地:Ubuntu 14.04
服务器:Centos 6.5

仅有的幸福仅有的幸福2749 days ago821

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-05-02 09:28:19

    Git also transfers your files to the server through ssh, why not use ssh directly?

    scp -r somefiles username@1.1.1.1:/home/www/ 
    

    Improve efficiency a little more, incremental update:

    rsync -avzPe ssh somefiles username@1.1.1.1:/home/www/
    

    If you only want to use git, you have to modify post-update.sample under hooks in the .git directory in your git warehouse on the server.
    Add a line of git pull and name it post-update and give it execution permissions (chmod +x post-update).

    reply
    0
  • ringa_lee

    ringa_lee2017-05-02 09:28:19

    There is a hook file in git, which can realize automatic deployment. You can search Baidu and Google for the specific usage. It can automatically deploy the program you uploaded from git to the folder you specify

    reply
    0
  • Cancelreply