git noob struggling to push development machine changes to remote production server part 2
on a remote server i have a rails 3 app. i understand that i cannot push changes to a non bare repository. so,
- on the production machine, in the rails root directory, i created a directory named '.git'
- cd into the new .git directory
- ran git init --bare
- then from my development machine entered this command: git push ssh://jay@domain.com:12345/开发者_如何转开发home/jay/public_html/domain/.git master:master
The push seemed successful because i got this msg:
Counting objects: 235, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (214/214), done.
Writing objects: 100% (235/235), 399.79 KiB, done.
Total 235 (delta 44), reused 0 (delta 0)
To ssh://jay@domain.com:12345/home/jay/public_html/domain/.git
* [new branch] master -> master
changes were made in the bare '.git' directory but no changes were made to the remote production machine code. Is there another command that i need to run after pushing the changes?
UPDATE: I am the only developer. There are only two repositories. 1. on my development machine i installed git and then ran init, add and commit 2. on my remote production server i installed git and performed the the steps above
I think you are looking for something like having git-hook - post-receive hook to be specific - in your bare repo that will push to other repo which is the "remote production machine code"
First of all, dont create a .git
directory. Just do a git init --bare
in the directory where you want the git repo. This need not be in public_html
. Now in your public_html\domain
clone the other bare repo. Now you have your production code. Setup a post-receive hook in the bare repo's hooks
folder and have that push to the other repo in public_html
. ( you may need to add a remote to the other repo ). This way, when you push from your development machine, the production code gets updated as well.
cd /home/repos/repo
git init --bare
cd /home/jay/public_html/domain
git clone ../../../repos/repo .
cd /home/repos/repo/hooks
vi post-receive
( add post-receive hook content, make it executable)
You can add a remote to the code repo with git remote add prod /home/jay/public_html/domain
. With that setup, you can have your post-receive hook do git push prod master
精彩评论