I used Mercurial (Hg) before, and it was ok to do something like at the local PC:
hg clone ssh://peter@hostingcompany.com/~/mysite.com
and then will have a local folder called mysite.com
, and I can edit its content, commit, and say hg push
and push it to the server. Of course, to have the content show up in the "working directory", I will have to ssh
there and do an hg up
.
With Git, if I do the same, at the server, do a
git init
git add .
git commit -m "ok"
and at the local PC, do a
git clone ssh://peter@hostingcompany.com/~/mysite.com
but when I edit a file and git push ssh://peter@foo.com/~/mysite.com master
, then it will refuse it, because it is not a "bare repository".
Is there a way to
- Push it anyway, like Hg?
- Or, better yet, push it and have it automatically do something like
hg up
-- is itgit checkout
, so that the content is immediately visual on mysite.com (using any web browser anywhere).
Update:
It seems that the usual practice is to push to a bare repo... but can we not use a bare repo and make (2) above work? If it is a practical way, then we don't have to stick to the "push to bare repo" rule?
If there are other reason still to push to a bare repo and clone on the server... then:
if the server had directories such as ~/mysite.com
and ~/other_folder
etc, then where should the repo for mysite.com
sit? mysite.com
is the content of the website, so if I put an index.html
, then any browser in the world can see it. So is it good to create a bare repo, let ~/mysite.com
clone from it, and on the local PC, use git push <path> master; ssh <path> "cd to that folder and do git checkout to update the content"
automatically by 1 line on the local PC? Will the line be git push ssh://peter@hostingcompany.com/~/mysite.com master; ssh ssh://peter@hostingcompany.com/~/mysite.com 'git pull; git checkout'
?