Advice on using Git to manage website development?

I am a designer who wants to ease the pain in managing the development of my sites. I only recently discovered Git, and so far it has been very easy to pick up. In my opinion, you can use Git as a way to deploy these changes using two or more repositories; one of which is the master. I am particularly interested in having a development environment, a testing environment, and a production site.

So, I have a few questions:

Is it possible to use git this way?

What's better; storing the main repository on the local computer and pushing the changes to the production and testing server? Or is it better to store the master on your production segment and pull it to the local computer to make changes?

If so, how would you perform any method?

+7
source share
2 answers

There may be some confusion here, so I will try to clarify the situation.

A repository is just a copy of your code. You can have several copies of your code (for example, several copies of your repository, for example: one on your development machine, one on your testing server and one on your production server). It all comes from the same code, you just can have each repository with different commits (a set of changes) or another branch.

My suggestion would be to work like this. You create a repository with your code by running in the root directory of the project you want to use with git.

git init 

Now you can create several branches of your code. One could be called a "master" (usually the name of a person), and it is used to store production code. Another branch can be called "development." So, when you start playing on your website, you will switch to the development branch in your local copy of your repository, make changes, commit this branch and push the changes to the repository on your test server (which you would normally save in the "development" branch ) You check your code, and then, when you feel that everything is in order, you merge development changes into master and then drag them into the production server repository (which is usually located in the "master" branch).

I highly recommend you use github.com , it can really simplify things, and also help you keep remote safe copies of your code.In addition, you do not need to create git servers to be able to make changes to every copy of your code, but you just update your copy of github, and later you can extract changes from each version of your code (e.g. testing and production).

Everything that I explained here can be a little confusing, you can check the book to understand the difference between the repository itself and the branch in the repository. git is a great choice for organizing your code. If you decide to go with him, you can take a look at this website http://gitimmersion.com/

+3
source

Great idea to use Git like this. From what I saw, most people have a host on their local machines and click on the production / testing server.

Here's a guide to Git for this: http://toroid.org/ams/git-website-howto

If you want to test the machine as well, repeat the steps described in "Remote repository" on another computer and add it as remote with a different name.

+3
source

All Articles