2

We currently have our development websites setup as a git repository. currently we publish the websites by using pulling into another directory and maintain this as the "production" versions of all of our sites. The downside to this is that it means I cannot break our customers out into separate cPanel accounts. To solve this I have created a cPanel account and then following the directions in this post

user@sv1 [/home/ncpn/public_html]# git init
Initialized empty Git repository in /home/ncpn/public_html/.git/
user@sv1 [/home/ncpn/public_html]# git remote add -f origin /home/tendesig/public_html/respond/app/sites
Updating origin
remote: Counting objects: 15586, done.
remote: Compressing objects: 100% (14816/14816), done.
remote: Total 15586 (delta 6694), reused 0 (delta 0)
Receiving objects: 100% (15586/15586), 949.18 MiB | 36.26 MiB/s, done.
Resolving deltas: 100% (6694/6694), done.
From /home/tendesig/public_html/respond/app/sites
 * [new branch]      master     -> origin/master
user@sv1 [/home/ncpn/public_html]# git config core.sparseCheckout true
user@sv1 [/home/ncpn/public_html]# echo "ncpn/" >> .git/info/sparse-checkout
user@sv1 [/home/ncpn/public_html]# git pull origin master

I have a few issues and dont even know if this is the best approach.

because this fetches the entire repository and if we did this using our current inventory, it would mean almost a gig of disk space used for each customer.

this is probably just a matter of syntax, but using the above commands, it puts the new data in /public_html/ncpn and I need it to be in just /public_html

Is using sparse checkout even the best approach for what I want to accomplish? If so how do I echo the checkout so that it copies the files into the current directory instead of say /public_html/ncpn?

Community
  • 1
  • 1
Destination Designs
  • 683
  • 1
  • 5
  • 17

1 Answers1

1

Is using sparse checkout even the best approach for what I want to accomplish?

I would prefer a branch per customer, instead of a subfolder.

If so how do I echo the checkout so that it copies the files into the current directory instead of say /public_html/ncpn?

You can checkout in an external folder, and make a symbolic link between /public_html and that folder.


If you go one branch per customer, you can (with git 2.5+) have:

  • the all repo fetched once
  • checkout multiple time (with git worktree)

See "Multiple working directories with Git?"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thanks I am looking into this. my git is currently 1.7.1 so i will need to upgrade before i can even give it a shot – Destination Designs Jan 12 '16 at 05:54
  • @DestinationDesigns Sure: 1.7.1 has been released in Dec... 2010! – VonC Jan 12 '16 at 05:55
  • I'm sure, its what ever the base install was with my ubunto server. since i am new to git, i never had a reason to upgrade it – Destination Designs Jan 12 '16 at 05:57
  • @DestinationDesigns Then the upgrade should be easy: http://stackoverflow.com/a/34469473/6309 – VonC Jan 12 '16 at 05:58
  • git version 2.7.0 !! Thank, I think a branch per customer is going to be the best route. what do you mean by the: all repo fetched once checkout multiple time (with git worktree) – Destination Designs Jan 12 '16 at 06:24
  • @Des I mean you are not cloning the repo multiple time. You are doing a checkout per client out of the same repo. – VonC Jan 12 '16 at 06:34
  • so if i am following this right, on an existing directory in my repository i would do something like this? git worktree add ncpn [ncpn] and that would make that a working tree with the existing files? – Destination Designs Jan 12 '16 at 06:40
  • @DestinationDesigns yes, but a given branch. You can checkout multiple branches in multiple folders out of *one* repo. – VonC Jan 12 '16 at 06:54
  • last question, i promise, but how do i make an existing directory a working tree. for example when I try # git worktree add --force ncpn [ncpn] i get the following: fatal: 'ncpn/' already exists – Destination Designs Jan 12 '16 at 07:17
  • @DestinationDesigns try it when the folder ncpn does not exist. (and if you have more questions, do not hesitate to add them to this thread) – VonC Jan 12 '16 at 07:20