WerkkreW
WerkkreW

Reputation: 364

Proper way to use git for website development?

So I have searched around this site, I have read the tutorial at gitimmersion.com, and various others as well, but I still have lingering questions which I am hoping someone can answer.

Basically I have a webserver, on that server I have two domains, dev.domain.com and the main site www.domain.com.

Right now, the "production" domain is a placeholder coming soon page, and dev.domain.com is the actual working site. Eventually git can/will be used to handle pushes from dev to production, but as of right now the site is still in development stage.

Recently, due to a few other people coming onto the project, I decided to use version control, specifically git. I have set up the webroot of my dev domain as a repository, and pushed it to codebasehq.

This is where I get confused.

I have figured out how to checkout the code, pull it, push it, make commits, etc. What I have not figured out, is the proper way to actually test development. Let me qualify that prior statement with an example:

When I was working on the site by myself I would simply work in an editor, save files, refresh my page, make sure I didn't have parse errors, make sure things worked right, etc.

How do I do that now?

Can we all have accounts on the box and sit inside the webroot of the dev.domain.com site and edit/test edits? Do we each need our own little LAMP server to test on on our workstations?

I am really confused about the proper way to handle this. If I check the code out to my local machine, I can edit files to my hearts content, but I would wind up having to make 400 commits/pushes just to test things and make corrections every time I forget a semicolon since I have no way to test it locally.

Am I missing something or is the answer as simple as "Sure you can all edit in the webroot and it will track changes on a per-user basis" or "No, you all need your own way to test your code before you push it out"

I have never developed anything collaboratively before, so I am used to just editing/testing on the fly, so please forgive my ignorance.

As a summary, here is what I am trying to accomplish:

Three person team developing website; dev.domain.com is the "testing/development" area on my webserver. At some point, www.domain.com will become the production landing point. All members of the development team have ssh access and accounts on the server.

How do I tie all of this together with git, keeping in mind that needing a local testing environment on my home machine is not ideal (but do-able), and that I have already established an account at codebasehq.com as the primary git repository which was created from the webroot of dev.domain.com.

Thanks in advance!

Upvotes: 3

Views: 1639

Answers (2)

eikimart
eikimart

Reputation: 21

This is what I do (reasonable people may disagree):

1) Test locally, using the LAMP stack on my workstation, while committing to git as I go.

2) When I'm ready to reincorporate my local branch, I push to origin. The repository is on my production server.

3) When we want to do a deployment test, it goes on a testing subdomain on the production server, say test.foo.com.

This is where it gets tricky: suppose document root for the production site is 'foo.com/httpdocs'. This is a symlink to one of foo.com/httpdocs1 or foo.com/httpdocs2. The subdomain document root is also a symlink, to the other directory, so if production is set to httpdocs1, testing is httpdocs2.

We deploy to the testing directory, then when we're satisfied everything is in place (assuming we want to upgrade the production site) we repoint the production symlink to the other directory as well. That way the changeover happens within a single atomic file-system operation, if you use perl rename or similar to change the symlink over (rather than unlinking and relinking).

That's maybe more detail than you wanted. The important point is that everyone in my organization tests and commits locally before pushing.

Upvotes: 2

shanethehat
shanethehat

Reputation: 15570

You should test locally, and only push in code that works.

Upvotes: 0

Related Questions