Git - deploy dist folder to different remote

pixelworlds picture pixelworlds · Sep 19, 2013 · Viewed 8.5k times · Source

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

Answer

VonC picture VonC · Sep 19, 2013

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: