views:

45

answers:

1

I have a personal laptop and a dev box and want a setup with following things in mind:

  1. I want to have my code working on both machines. (That means I cannot have --bare repo.)
  2. I want to develop on my laptop
  3. I want to push to dev box from time to time.
  4. This is mainly for web development.

I tried initializing a Git repo with code on dev box and cloned in on my laptop. I could not push changes to dev box though. It gives me the error that I am pushing to a non-bare repo.

Then I tried --bare repo and it worked but then I cannot run the code sitting on dev box (or can I)?

Any ideas on how to achieve this kind of setup?

Thanks.

+4  A: 

One way to solve this is to create a third repo (that you can think of as the "main" repository) that is --bare. To share changes, you can push to the bare repository from one machine and pull from the other.

If you put this bare repo on the web box, then you can set up a post-commit hook to automatically extract the files from the main repo to the (non-bare) repo that's used by the web server.

I usually don't set up such a post-commit hook, but my workflow is generally:

  • make change locally (laptop in your case)
  • ensure it works in test environment
  • commit
  • push to bare repo
  • on web server, pull from bare repo into working dir
Greg Hewgill
Yep, that's what you'd want to do.
Wade Williams
@ Greg: So you do exactly the same thing as you suggested me except for the 'hook' part? Am I right?
AJ
@AJ: Correct, I don't use automatic hooks like that but other people do, and you can choose to or not.
Greg Hewgill
Thanks a lot. Wonder why that didn't occur to me? Me dumbo!
AJ