Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - deploy dist folder to different remote

I'm trying to figure out a way to deploy a dist folder to a different remote repo using Git.

The working project is stored in an app folder. I use grunt to optimize and compile the working project into a dist folder. I want to know if there is a way I can than use git to push only the dist folder to a different remote than the origin that the rest of the project uses.

Obviously, I just need the dist folder to go live. Not the whole project.

I tried looking into Git Subtree - but I'm not sure that I'm understanding the concept or if I can use it to accomplish what I'm trying to do.

Any advice would be extremely helpful!

Thanks in advance!

Rich

like image 806
pixelworlds Avatar asked Sep 19 '13 01:09

pixelworlds


1 Answers

You can:

  • make dist as an independent repo within your current repo.
  • declare dist as a submodule: see Git Submodules.
  • set a remote within the dist repo referencing your production server.

    git remote add prod /url/to/your/prod/server
    
  • push from that submodule

    cd dist
    git push prod master
    

That supposes you have, on your server:

  • setup a bare repo dist.git
  • put an post-receive hook which will, on receiving the push, go to the actual dist folder, and checkout the content of what you just pushed.
    See an example at "how do I deploy multiple branches to different directories via git push?"
like image 154
VonC Avatar answered Oct 03 '22 05:10

VonC