git repository to staging site to live site
Asked Answered
A

2

5

I'm just learning git and its basic fundamentals. I've got a live Magento store running and need to version control it asap. I've got git loaded on my work machine and have played around with setting up repositories, adding, committing and pushing files. I've tested my setup with Assembla and a free account (for now) and all is good.

I am still having trouble going about the physical changes though. I want to achieve the following (I think!):

  1. Checkout files needed from live site to work with on local machine
  2. Do changes locally from within Dreamweaver (I am using GITweaver and have that easily communicating with my repo) (Also, I am not opposed to changing text editors/IDE's if there is a better solution)
  3. Push repo to 'staging' site for review & testing with my partner. This is where I'm currently lost. What's the process of sending a repo to a live site?
  4. After review and changes are accepted, push repo to 'live' site.

So there's several important questions I need help with here.

  • Do you checkout files from a live site or a stage site? Is there any preferred method?
  • Is a stage site supposed to mirror a live site all the time?
  • What is the purpose of a 'dev' site and a 'stage' site - aren't they the same?
  • What do most people do in there setups and why? I need a good explanation of stage vs dev.

Some helpful background for our store/project:

  • I am the only developer and I will probably remain the only developer for some time
  • I am using a Windows machine to develop on and our hosting is through HostGator
  • My partner will only need to see the stage site so we can look at changes together, he has no need to view the repository ever.

I would be thrilled if someone could point out a guided tutorial or similar for people like me who did everything backwards and now don't have the time to learn git one step at a time.

Antoniettaantonin answered 18/1, 2012 at 20:42 Comment(2)
Is your hosting shared or VPS?Greatest
Unfortunately it is shared atm.Antoniettaantonin
D
5

What's the process of sending a repo to a live site?

Git does not have a facility for this built in. You'll want to write a script that periodically (say, every five minutes) or on demand pulls some branch from your central repo. (I'm assuming you have a Git server somewhere that functions as such.)

You can do the same thing for the production environment, by having the staging server pull, say, master, and having the production server pull the branch production.

Dore answered 18/1, 2012 at 20:51 Comment(5)
I've read about 20 different blog entries, etc. on git already and this is the first I'm hearing about that which makes perfect sense, so thanks! Do you have any suggestions on where to turn for help making one?Antoniettaantonin
@JaredEitnier: if you have cron, you can use a command like cd WHERE_THE_WEBSITE_LIVES && git pull origin production &>/dev/null. Just make sure the cron user has the necessary keys to communicate with the Git server securely. You should set those up when you first git clone the repo into the deployment environment.Dore
@larsmans just to elaborate, this can be done with hooks, but I'm not sure how far you'd get on a shared hosting server. It might be a pain, as I doubt they'd allow git.Greatest
@melee: if they allow SSH or even just HTTPS, you can at least pull securely. Without that, you can even pull over HTTP.Dore
well, my repo hosting is not under hostgator which is my files host. hostgator doesn't support repos, only the client so in my case i had to host elsewhere.Antoniettaantonin
G
4

@larsmans has some pretty solid advice for you - I figured I'd cover your other points to try to help you out.

Think of your dev server as where you (and possibly other developers) make, test, and finalize changes. Think of the stage server as where you show potential changes to other stakeholders before they go to the production or live site.

I personally use a branch for each server (we even specify local machines as alpha servers before they even go to dev/staging), and think of them hierarchically:

  1. prod
  2. stage
  3. dev
  4. alpha

Changes start in alpha and are merged upwards - so a bugfix that starts in alpha is merged or cherry-picked into dev, checked, then pushed upwards to stage and ultimately to prod. To update, the branches are just pulled and synced that way. Each server has a copy of the repo, giving extra redundancy in the case of any issues.

We have our own git repository using gitolite, which we've (easily) customized to handle the push and pull duties described in @larsman's answers - unfortunately, since you're on a shared host, this might not be the ideal solution for you. Either way, you should consider running a VPS, as Magento is very resource-intensive and load times suffer greatly - this is first hand advice from someone who has tried to make Magento work on HostGator.

Greatest answered 18/1, 2012 at 21:20 Comment(5)
That's a good explanation, thanks. I think for my rather small operation I can do without a 'stage' and just use a dev server along with my production server. Down the road we might have a need for that but I need to keep things extra simple for now.Antoniettaantonin
If you don't have a lot of stakeholders waiting to approve changes, it really isn't necessary to have a staging server (in my opinion), so you should be ok :)Greatest
I know, it's not related with your question but this is my method. I used static IP in my home which I requested from ISP. Then, I bought Atlassian Fisheye, its just 10$ for starters. I used regularly Fisheye to organize my git repository. I do everything in my home server then deploy the production server. The reason is why I choose this, flexibility. Because, I am always face of same issue like you, specifically shared hosting environment.Beesley
How can I from my local machine do a repository push that is hosted on a remote server to my separate web host then? For example, Assembla (my repo host) has a paid feature called 'FTP Build' which lets me commit and push the repo to any FTP url I specify with 1 click. How could I do that on my machine vs. paying extra? I believe this has to do all with git hooks right?Antoniettaantonin
Jared, my host work under VMware workstation. I did setup on my router to catch web and ftp request to directly VMware workstation. As you might guess, you can't do everything via git, like a shared hosting environment is because of the provider restrictions. Your way is fine but in my opinion, isn't necessary "FTP Build" feature. I can get .zip package from my repository then deploy the server via normal FTP. It seems there is no difference in your way.Beesley

© 2022 - 2024 — McMap. All rights reserved.