简体   繁体   English

如何将我的本地存储库与实时网站向前和向后同步? 吉特

[英]How do I sync my local repo with my live website, backwards and forwards? Git

I have figured a way (using a few different tutorials) on how to push a local repo to a remote --bare repo that the uses a post-receive hook to push the contents to a live location. 我已经找到了一种方法(使用一些不同的教程)来说明如何将本地存储库推送到远程的裸露存储库,该存储库使用后接收挂钩将内容推送到实时位置。

So in brief explanation of my current situation 所以简要解释一下我目前的情况

Make a change to a website locally
Use "git push live master"
Commit gets uploaded to remote repo
Remote repo pushes the contents to /home/unixuser/public_html

But say on this website there is an upload form where an admin can upload articles (on the live site), or where users can upload profile images. 但是请说在此网站上有一个上传表单,管理员可以在其中上传文章(在实时站点上),或者用户可以在其中上传个人资料图片。 How would I sync my local repo with the new content in "public_html" as the repo is actually stored somewhere else on the server? 由于存储库实际上存储在服务器上的其他位置,我该如何将本地存储库与“ public_html”中的新内容同步?

This sounds pretty simple but whenever I search for this I seem to get just the part on how to do post-receive scripts and how to upload, rather than the download part... or an over bloated explanation that leaves me confused. 这听起来很简单,但是每当我搜索此内容时,我似乎只会得到关于如何执行接收后脚本和如何上传的部分,而不是下载部分……或者过分膨胀的解释,这让我感到困惑。 Is there a simplified answer to this question or am I possibly going about the whole thing the wrong way. 这个问题是否有简化的答案,或者我可能会以错误的方式处理整件事。

Any answers are appreciated, thanks! 任何答案表示赞赏,谢谢!

Maybe you just need a copy script for whenever a new file is uploaded to copy it in your repo, commit + push that. 也许只要上载新文件以将其复制到您的存储库中,就只需要一个复制脚本即可,提交并推送。

An other solution would be to use a second repository: git-ignore the upload directory in your current repo. 另一种解决方案是使用第二个存储库:git-ignore当前仓库中的上载目录。 use a second repo which runs on the server, watching the upload directory - you just need to syncronize it to your local machine then. 使用服务器上运行的第二个仓库,查看上传目录-您只需要将其同步到本地计算机即可。 with git-ignore in the old repo, you could actually place the "upload"-repo inside the folder structure of the old repo (like it is on your server folder structure?) 在旧仓库中使用git-ignore,您实际上可以将“ upload” -repo放在旧仓库的文件夹结构内(就像它在服务器文件夹结构中一样?)

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

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