I want to use git to manage my development, integration test and production environments. I\'ve looked around but can\'t seem to find a simple explanation of how (eg Git -
If you have ssh connection to the server, you can add a git remote directly to the repository on the server. Something like:
git add remote production sshUser@example.com:/path/to/repo/.git
Then, to deploy,
git push production branch
That said, you probably shouldn't have your production code served from a git repository. Much better is to set up a repository outside your web root and use a post-receive
hook to copy the code to the web root. This appears to be outlined here:
Deploy a project using Git push
Git is not (originally) meant for synchronizing working copies but repositories that is Git's commits/branches/refs/etc.
What your want to do I would call a remote checkout. There is hundreds of other ways to do. I have two ideas: As you have setup an ssh-connection the big work is done:
1) use git and ssh
git push origin my_branch
ssh user@server "(cd remote-dir-where-your-repo-is; git checkout -f my_branch;)"
2) Use rsync
rsync -av . ssh://user@server/dir --exclude=.git