2

I have set up a remote directory and initialized .git within it.

I can push to this repo but I need it to pull the project into the directory to mimic the structure init my local repo.

Is this where I would need to run a post-receive hook? How do I pull the project files from the local .git in the directory?

Thanks for any help.

boom
  • 9,524
  • 8
  • 39
  • 58
  • How would your local directory structure differ from that of the remote, if they are both contained within the git-initialized directory? – Wade Williams Oct 19 '13 at 21:22
  • @WillWilliams When I push to the remote only the hidden files are getting updated. I can clone and pull from `workingdir/.git` and get the files but it doesn't automatically build the project in `workingdir` – boom Oct 19 '13 at 21:38

2 Answers2

0

Using git push will let you push the updates in a git repository around to different remotes.

When you push to a remote, all you're doing is sending the changes to the git repository. If you want the directory structure to change, you'll need to somehow check out the latest version of the code.

You could do this using a post-receive hook. You'll need to fast forward the remote branch. Beware that the client won't disconnect until after the post receive hook completes.

Here's the quick overview of what you're looking for: http://toroid.org/ams/git-website-howto

See this SO post: Git Post-Receive Hook for Website Staging

This site seems helpful as well: http://githooks.com/

Community
  • 1
  • 1
Wade Williams
  • 3,195
  • 1
  • 23
  • 33
  • The idea is that I push to the the remove, it updates the project files and then restarts the process. I have figured out restarting the process on file change. I just need to pull from the files from .git when after it receives a push. Does this make sense? Thanks! – boom Oct 19 '13 at 21:35
  • I see what you're trying to do now. The files aren't updating because the remote is just receiving the changes in git - you want the remote to check out or pull in the latest changes. – Wade Williams Oct 20 '13 at 16:43
0

Create a hook in .git/hooks called post-receive. The file should contain the following...

#!/bin/sh
GIT_WORK_TREE=/path/to/where/you/want/working/files git checkout -f

I had some problems trying to get this to work with a git repo that wasn't --bare (use git init --bare when setting up, then put the working directory somewhere else)

example:

mkdir yourbarerepo.git
cd yourbarerepo.git
git init --bare
cd hooks
touch post-receive
nano post-recieve
  #paste in contents above
  #make sure the path where you want the working files to go is already created
boom
  • 9,524
  • 8
  • 39
  • 58