15

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

pjs
  • 18,696
  • 4
  • 27
  • 56
pixelworlds
  • 818
  • 2
  • 11
  • 22

2 Answers2

10

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:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
6

If dist is also being revisioned by your repository you can also use subtree for your needs.

Assuming you already have a remote repository setup in your local repository, after you have committed your changes to dist the command for a subtree push would be:

git subtree push --prefix dist distRemote remoteBranch

What this command is doing is first creating a new set of commits in which dist is the root folder and only changes to dist appear. This commit is then pushed to the remoteBranch in the distRemote repository.

Maic López Sáenz
  • 10,385
  • 4
  • 44
  • 57