I have a personal laptop and a development box and want a setup with following things in mind:
- I want to have my code working on both machines. (That means I cannot have
--barerepo.) - I want to develop on my laptop.
- I want to push to dev box from time to time.
- 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?
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: