search

Home  >  Q&A  >  body text

GIT远程同步的问题

以前一直用svn,转入git没多久,菜鸟一只 过去一直是在服务器的server目录下git init一个仓库,然后本地客户端通过SSH连接clone这个仓库。每次push之后,然后再通过服务器hooks执行git reset --hard。以同步。 我觉得这个方法肯定是有问题,请问能否更简单一些

黄舟黄舟2810 days ago568

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-21 11:19:31

    If the code warehouse on your server is only used as a code warehouse, that is, it is the same as the SVN warehouse, then you should use:

    git init --bare
    

    to initialize. The warehouse created in this way does not contain a working directory, so there is no need to use a hook to reset.

    But if your server is also a production environment and you want the code to be automatically deployed every time you push it, you will inevitably need to clone a working directory on the server and use a hook to automatically synchronize the working directory after each push. .

    reply
    0
  • ringa_lee

    ringa_lee2017-04-21 11:19:31

    How to execute git reset --hard on server hook?

    reply
    0
  • Cancelreply