我正在尝试将 PHP/MySQL 网络应用程序(基于 CodeIgniter 2.01 框架构建)移动到 GIT 存储库。问题是为了增加安全性,我已经实现了分离应用程序部分(应用程序和系统文件夹)和 Web 文件(index.php、图像、css、js 等文件夹)的最佳实践。 Web 文件位于/var/www,应用程序位于/data/company/apps/myapp。
由于我想保留这种额外的安全性,我该如何将具有多个位置的项目迁移到 GIT 中?
最佳答案
我认为您的 Git 存储库的结构和已部署 文件的结构不需要匹配:
- 要么添加一个额外的步骤(例如
post-receive
Hook )将文件从 Git 存储库复制到正确的系统路径(将 SCM -- 源代码控制管理 -- 从 RM 中分离出来 - - 发布管理), - 或者您将两个系统路径直接链接到 Git 存储库中的两个相关目录。
我在评论中补充说:
if you reorganize your repo's content in order to have to directories with the relevant content, you can make two
git archive
for each directory, and extract them in the right places.
I found the solution with the following commands in
post-update
:
git archive --format=tar master:guts/ | \
tar -C /data/company/apps/myapp -x
git archive --format=tar master:skin/ | tar -C /var/www -x
关于git - 将 GIT 用于在多个位置具有目录的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5590995/