Using GIT with projects that have directories in m

2019-03-31 19:46发布

I'm in the middle of trying to move a PHP/MySQL web app (built on CodeIgniter 2.01 framework) to a GIT repository. The problem is for added security I've implemented the best practice of separating the application part (application & system folders) and the web files (index.php, images, css, js, etc. folders). The web files are located in /var/www and the application stuff is located in /data/company/apps/myapp.

Since I would like to keep this added security, how do I migrate a project that has multiple locations like this into GIT?

1条回答
走好不送
2楼-- · 2019-03-31 20:25

I don't think the structure of your Git repository and the structure of the deployed files need to match:

  • either you add an extra step (post-receive hook for instance) copying the files from your Git repo to the right system paths (you separate SCM -- Source Control management -- from RM -- Release Management),
  • or you link directly your two system paths to the two relevant directories within your Git repo.

I added in the comments:

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.

To which the OP crashintoty replied:

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
查看更多
登录 后发表回答