Git for web development (procedure method)

I am wondering what is your method of web development procedure using Git?

  • When you finish coding, do you just overwrite files on FTP on a live server?

  • How does git handle the number of versions of the same project? e.g. v1, v1.5, etc.

  • Let's say 2 people work on a project at the local level (the same office), how do you work together? Should I continue to ask them to provide me with the source code (excluding USB?) For merging?

  • Can two people work in one project on one server? Wouldn't that be easier than question 3?

+8
git version-control dvcs php
source share
3 answers

The idea of ​​git is that it really takes care of all this for you.

  • When you write code, you transfer your code, and you can output it to the server. git tracks changes, so it's easy to roll back to a previous version.
  • It keeps track of the versions of files as they change, so you can easily undo any changes that have been made in the past, see the tags for more details.
  • NO You can redirect your changes to the server, and another person can make these changes. Some merging should happen, but its pretty easy with git. There is no need to transfer files from one developer to another. Branching and merging are discussed here .
  • Yes. This is an idea.

To better understand the concepts of a distributed version control system, you can read this Joel Spolsky tutorial . It's about Mercurial, but you will find the concepts very similar, and this is probably the best tutorial written on this subject on the Internet.

+8
source share

This is how I do it.

Each developer has their own git repository to develop their code. You, as a merger, keep a third repository, and this repository has separate branches for each developer, for your test system and your production site.

Your developers can push your changes to you, or you can pull their changes from them into branches specifically for them. You have a branch that you control that contains the combined code in a state for testing. You either use git -cherry-pick, or maybe just git-merge, to push your changes to your test branch, you have tested things (and possibly made your own changes), or sent development error messages, and you - enable their changes). When you are happy, you will be transferred to the “production” branch. This usually comes from the test branch, but with the changes necessary for a living system (I always find something, even if it's just a database name and password).

I usually use git hook with some code that checks which branch I am joining in and then uses rsync via ssh to direct the code to my production site.

#!/bin/bash branch=$(git branch | sed -ns/^\*\ //p) version=$(git describe --tags) cd "$git rev-parse --show cdup)" if [ "$branch" == "production" ]; then echo "?php echo '$version';?>" > web/version.inc rsync -axq --delete web/ site:public_html/ fi 
0
source share

google "git flow", it shows you a way to control and let go whenever you want.

For deployment through a branch, see:

Deploy a project using git push

0
source share

All Articles