简体   繁体   English

用于实时站点部署的Git:如何从实时版本中获取文件?

[英]Git for live site deployment : How to get files from the live version?

From my Workstation, I can “push” modification to a git bare repository on my server, which contains a Hook that runs "git checkout -f", so I can deploy my site via Git. 从我的工作站,我可以将修改“推送”到服务器上的git裸存储库,该存储库包含一个运行“ git checkout -f”的Hook,因此可以通过Git部署我的站点。

The thing is that users of my website can upload files (like images). 问题是我网站的用户可以上传文件(如图像)。 And without those files, the website can't work. 没有这些文件,该网站将无法正常工作。 So my question is : How can I get to my workstation the modifications on the live version ? 所以我的问题是: 如何将实时版本的修改带到我的工作站? (like uploaded files by users). (例如用户上传的文件)。

** EDIT : Some details about the procedure I followed to set this configuration : ** **编辑:有关设置该配置的步骤的一些详细信息:**

On the server, which already contains the site : 在已经包含该站点的服务器上:

 $ cd /home/website/www $ git init $ git add * $ git commit -m 'First commit !' 

... then create a bare repository... ...然后创建一个裸仓库...

 $ cd /home/website $ mkdir www.git $ cd www.git $ git init --bare 

... then set hooks stuf... ...然后设置挂钩stuf ...

 $ git config core.bare false $ git config core.worktree /home/website/www $ git config receive.denycurrentbranch ignore $ cat > hooks/post-receive #!/bin/sh GIT_WORK_TREE=/home/site/www git checkout -f 

... then commit for the bare repository : ...然后提交裸仓库:

 $ git add /home/website/www $ git commit -m "First commit of the bare repository" On my workstation, on a new folder, to get the whole directory : $ mkdir /Users/me/Sites/website/ $ git init $ git remote add live ssh://root@myserver.com/home/website/www.git $ git pull live master 

Then it works. 然后就可以了。 If i modify files on my workstation and want to make them live, I just have to “git push live master”. 如果我在工作站上修改文件并希望使它们生效,则只需“ git push live master”。

I would not recommend to commit those images back to the bare repo (if those images are large or numerous, the size of the bare repo could quickly becomes too important for easy cloning) 我不建议将这些映像提交回裸存储库(如果这些映像很大或很多,则裸存储库的大小可能很快变得太重要而无法轻松克隆)

But you can use you hook to copy back those images in some shared directory that you can then access from your workstation (and that you can rsync, in order to get only the delta). 但是您可以使用钩子将这些映像复制回某个共享目录中,然后可以从工作站访问这些映像(并且可以rsync以便仅获取增量)。
Basically, I would recommend getting those images back without using git. 基本上,我建议不要使用git来恢复这些图像。

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

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