1

I have a remote repository for a website which I am developing on my local machine.

I use git flow for neat branching model, so my branches are:

  • master
  • develop
  • feature/one
  • feature/two
  • release/one
  • release/two
  • etc

The simplified work flow is as follows:

  • make changes in develop
  • push develop to backup server
  • checkout to master
  • merge master with develop`
  • push master to live server

What I want to achieve, is that when I push master branch to live server, I should be able to instantly see changes when accessing website by URL.

The problem is that I can't really push master, because it is checked out on live server.

Can I write a pre-push hook which will do a checkout to dummy branch on remote, and a post-push hook which will do a checkout back to master? The point is that these hooks involves execution of git commands on remote and I'm not sure how to do this.

Would appreciate any examples very much!

Edward Ruchevits
  • 6,411
  • 12
  • 51
  • 86

1 Answers1

2

You should push to master on a bare repo.

Then a post-receive hook can checkout that bare rpeo on your live server.

cd /path/to/bare/repo.git
GIT_WORK_TREE=/path/to/live/server git checkout -f
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250