Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GIT with projects that have directories in multiple locations

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?

like image 689
crashintoty Avatar asked Jan 30 '26 05:01

crashintoty


1 Answers

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
like image 130
VonC Avatar answered Jan 31 '26 20:01

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!