In production, I maintain two sites – beta and release. Each points to a different directory via a soft link (e.g.)
beta_public_html -> /home/scott/myapp/trunk/public
public_html -> /home/scott/myapp/branches/1.2.3/public
I’m a longtime svn user, moving to git. I’m used to deploying via svn update and changing the soft link on a new branch, things are pretty simple.
Now I’m moving to git. I still need to have the two soft links (it’s a Rails app using Passenger), though now I want them to point to two different git branches (“beta” and “release”, say). And I want to be able to update them via git push (or git pull).
Question Part 1: I’m not sure the best way to do this.
The way I had started to do it was to just deploy to two different remotes, e.g.
git push ssh://scott@x.com/home/scott/myapp-beta beta
git push ssh://scott@x.com/home/scott/myapp-release release
But this doesn’t work because push doesn’t update the working tree by default.
So I go into the remote directories and run git reset –hard the first time, and it pulls the working tree. But I push again and I can’t get the new push to show up – it just stays at the initial one.
(BTW, note that I can’t seem to push to “myapp-beta.git” – that fails, I have to push to the directory name. I am worried that this is part of the problem, but I don’t know what I did wrong here.)
So, if the answer to Question 1 is that my method is fine, Question Part 2: what’s wrong with what I’m actually doing? If there are hooks I should be using, can someone point me to them?
(An answer to Question 1 that says “run these seven manual steps” will not be a terribly useful answer, seeing as svn checkout + ln -s are two steps.)
Thanks. I want to get back to writing code.
The article Git push is worse than worsless has an interesting discussion about a similar issue.
One of its solution and conclusion involves:
So in your case,
In short: one step:
git push. No more link to manage (since the directory no longer represent a branch in Git, unlike SVN)Regarding the hook part, a post-receive hook in the bare repo could be all what you need
See Git Tip: Auto update working tree via post-receive hook
Note:
‘env -i’ does just that: it ignores the inherited environment completely and uses only the supplied variables and values.