A web-focused Git workflow
joemaller.com
joemaller.com
As for me, I just type the extra "git pull" or "git push". It's not a big deal for my use case right now, though if it were I know it's fairly simple to add hooks that automatically pull changes into your running copy ("Prime"), though I'm not sure I want that. I like pushing to the hub and controlling when those changes get rolled out without having to maintain a ton of different branches.
BTW, in Mercurial it is indeed just a hook. And in Darcs even that hook isn't needed.
And FWIW, Mercurial can handle bare repositories, too.
Without any hooks, the next "git commit" on the remote system would add a patch that reverts the uploaded changes. This is very contra-intuitive and could be the source of big mistakes. It's a really nasty trap if you don't watch out!
I like more the approach of Marcurial and Darcs where "not trashing" is the default.
Also, Git was never designed for minimalism, but rather for feature-completeness. In contrast, Mercurial was designed with a minimalistic approach (as least in the beginning), so I find it especially strange that Mercurial provides a proper "push" but Git doesn't.
1) "Pushing to a live site is a bad idea."
2) "Pushing into a non-bare repo is a bad idea."
both don't hold.Regarding 1): It depends on how well-tested the code you're pushing is. Also, conceptually it doesn't matter whether you deploy by pushing to the live system, or by triggering a script on the live system which pulls from the test system. Both achieve exactly the same, so both are equally good or bad. However, the push is more comfortable.
Regarding 2): I have a scenario at home where such a push makes a lot of sense. There is a stationary computer and a laptop, both of which have a common document repository (using Mercurial). Synchronization happens when the laptop is at home. It's just "hg pull -u ; hg push". The laptop needs access to the stationary computer, but not vice versa.
If I avoided the push, I'd have to trigger a script on the stationary computer which in turn pulls from the laptop. Net result: One more script and one more communication channel, i.e. more work and less security.
So please be careful with exaggerated generalizations.
About (2), the script approach is the right one here. Again, just because you have some case where pushing to a working copy is easier doesn't mean git should make that a feature. Write the script once, problem solved.
Also, nothing against scripting. Mercurial needed a small hook, too. But Git's default push behaviour is not only worthless, it's dangerous and risks unexpected reverts of changesets. I already explained this in: http://news.ycombinator.com/item?id=1158563
Git should either have a sane default implementation, or should refuse to push to non-bare repositories. But its current implementation doesn't make any sense. Providing dangerous defaults because people shouldn't use it anyway? That's plain ignorance.
(However, I agree that automatic deployment is indeed a bad idea, no matter whether it uses push or pull. But that's off-topic.)
whoa--- how else do people deploy to live sites? i can't imagine not using version control. or am i missing some nuance of the situation?
I've never understood how "git pull" is supposed to configure a production server correctly. What do people do, put /usr/bin and /usr/lib64 and /etc in git?
However, it is quite common to use rsync for deployment of everything: system, application, etc. from test to production, without any version control needed. This works especially well when using vservers.
i guess there are at least two views of updating web servers: the servers themselves and the web application. the latter is a lot more self contained. i forgot about the former. i set that up once, backed it up, and pray that i don't have to touch it again :-p