1

I have "myapp" folder under git. Several branches are used (master, dev, test, prod, ...). I'd like to make an external shell script (script that is not in the "myapp" folder) to deploy a given branch to a web server.

How can I select a dedicated branch from an external script?

The idea is to use something like:

cp -r myapp@dev my_we_folder_path 
# myapp@dev beeing the dev branch of myapp folder

Obviously, myapp@dev is not a correct git notation, but is there something equivalent in git?

Luc
  • 16,604
  • 34
  • 121
  • 183
  • 1
    http://stackoverflow.com/questions/4155144/git-post-receive-hook-to-update-multiple-servers could help: post-receive hook. – VonC Nov 14 '11 at 08:59
  • 1
    @VonC Thanks, that seems great ! I think this is exactly what I need. Could you make it a Answer ? – Luc Nov 14 '11 at 09:57

2 Answers2

3

As illustrated by the SO question "git post-receive hook to update multiple servers", the usual way of implementing that feature is through a post-receive hook similar to this one.

The idea is to, on new commits, make an archive of your git repo and extract it/rsync it where you need to deploy it.
As mentioned in "git-archive vs. cp", this is better than just cp an all git repo.
And this is consistent with the practice of not having any VCS feature on the deployment platform, and keep only what you need to run your program in a production environment.

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

You might want to check out what I learned here about securely deploying a git project to a remote webserver without exposing your repo to your webserver: https://stackoverflow.com/a/18941021/470749

That code could probably be modified for your needs.

Community
  • 1
  • 1
Ryan
  • 22,332
  • 31
  • 176
  • 357