0

on a remote server i have a rails 3 app. i understand that i cannot push changes to a non bare repository. so,

  1. on the production machine, in the rails root directory, i created a directory named '.git'
  2. cd into the new .git directory
  3. ran git init --bare
  4. 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

Jay
  • 6,206
  • 11
  • 48
  • 82

1 Answers1

3

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

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • The OP will still have the same problem as described in [their previous question](http://stackoverflow.com/questions/6089267/git-noob-struggling-to-push-development-machine-changes-to-remote-production-serv) with a post-receive hook that pushes to a non-bare repository for deployment. The solutions that I described there still apply, of course. – Mark Longair May 22 '11 at 20:46
  • you got me 90% of the way there. I'm still wrestling with the latter portion of your solution. – Jay May 22 '11 at 23:25
  • and @MarkLongair, after i pushed the devel files to the remote server, i created some changes and was able to push them to the repository. Now... just a matter of the post-receive hook. – Jay May 22 '11 at 23:35