I am new to Git and am trying to learn it and implement it in my environment at the same time. I’ve spent a week reading, watching videos/tutorials and following their guides but still can’t figure out how to implement Git in a webserver environment.
I have two servers both running apache, both serving the same website.
one for production, let’s say it’s available at http://production/
one for development, let’s say it’s at http://development/
I want to make my edits on the dev box and then push them over to the production server.
So far I’ve tried creating two separate repos, one on each box, but I get messages in gitbash about not being able to push into a non-bare repo when I try and push from the dev-box repo to the prod-box repo.
Then I tried creating a bare repo on the production box instead, and I could successfully push those files… but it’s a webserver, and so there were no files being served in the web directory. Http://production/ displays nothing because it’s a bare repo.
So then I tried cloning that bare repo into a /htdocs/ repo so that I had physical copies of files to be served by the webserver.
That so far seems to work. I can now make edits on the development box, push them to the production server, then from the production server, pull them into the cloned repo from the bare repo. So far so good!
My next dilemma is that two people work on the development box, each making changes that should be separately tracked so as not to commit someone else’s half-complete code on to the production server.
So I created branches on the development box, one for each person, but whenever I checkout a branch, it replaces the content in the physical files which means one person’s edits will only ever be visible by browser at the http://development/ URL at a given time, and that won’t work.
So then I tried to clone the dev repo into two separate repos, one for each person. Now making each persons’ edits visible at http://development/personA and then http://development/personB, but same problem as before, I can’t push edits to files into the non-bare dev-repo!
Hopefully it’s apparent that I am lost!
I can’t figure out how to set up my repos. Clones? Branches? Bare repos? Which one goes where?
I have two servers:
a production box that displays live content
a development box that displays the same content and is edited by two people
If anyone could suggest how I should set up my repos I would be very very grateful