Features:
1. You can quickly switch between project branches.
2. roll back the version of a branch.
3. You do not need to modify the configuration file (defined for projects) for each branch switch)
4. You do not need to create/switch virtual directories/domain names because they are all in the same directory.
5. Are these attractive to you? If you like it, join in.
What is git?
Git is an open-source version control software developed by Linux Torvalds to help manage Linux and kernel development.
It features fast, open-source, and distributed management systems.
It canCodeTo remove the error code.
Or, you can easily track who modified the content of the Code.
Comparison: centralized Version Control
Centralized version control systems generally adopt two methods:
Some systems provide file locks to prevent parallel access by multiple users. These systems lock files so that only one developer has write permission to the central repository at a certain time.
Other tools, such as SVN, allow multiple developers to edit the same file at the same time, and provide some mechanisms to merge these modifications later.
Tools such as CVS and SVN are deployed on the server. Each time you need to remotely update them to the local machine, the conflicts are resolved and submitted here.
This disadvantage is obvious. If the server crashes for several hours, your code may not be submitted within these hours.
Matching diagram:
Illustration:Code is centrally deployed on one server. Each computer must update the code on the server and submit the modification to the server.
Disadvantages: If the Version Control Server fails, it may affect the development of the entire project, because developers cannot submit and others cannot obtain the code, the most important thing is that the Code cannot be backed up from time to time, making changes more risky.If you cannot submit files, view historical version records, and create project branches on an airplane, train, or in some situations without a network connection, and so on.
Comparison: distributed version control
Git and SVN have their own centralized version libraries or servers.
However, git is more inclined to be used in the distributed mode, so that it will clone a version library on its own machine after chectout code on each developer-centered version Library/server.
If you are on a plane, on a train, or in some situations without a network connection, you can submit a file to view historical version records, create a project branch, and so on.
Git stores the content in metadata mode, while SVN stores the content by file:
All resource control systems hide the object metadata in a folder such as. SVN and. CVs.
Compare the size of the. Git directory with that of. SVN.
The. Git directory is a clone version library on your machine. It owns everything on the central version library, such as tags, branches, and version records.
Matching diagram:
Illustration:The developer clones a copy of the code from the version Library/server and can create/switch branches at will. The code can be switched back and forth in version 1 and Version 2 without affecting other versions.
Cloning a developer's machine into a server also provides features such as Viewing History, creating, and merging branches.
Operating Environment
Operating System: Mac OS
VM: VMWare Fusion
Virtual System: centos 5.5 +
Operation User: Root
Purpose: To build git version control.
Install dependency library and Version Control Software
# Install git ##################################### ##################
#Git dependent Library
Yum install-y gettext-devel expat-devel curl-devel zlib-devel OpenSSL-devel
# Centos
Http://codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
# Mac OS
Install the latest version of xcode.
# Windows msysgit
Http://code.google.com/p/msysgit/downloads/list
# Ubuntu
Sudo apt-Get install git Git-core(The software source is not found, and the tar.gz package installation package is recommended)
# Install git end #################################### ################
#Gitosis (GIT environment)
Install git and install gitosis
Install git
#Directory for storing software packages
CD/web/git
Tar-zxvf git-latest.tar.gz
CD git-2011-12-14/#The name of the extracted directory may vary according to the current version.
Make-J6
# If the libiconv. So library cannot be found, set the soft connection.
Ln-S/usr/local/lib/libiconv. so.2/usr/lib/libiconv. so.2
Make install
#Test whether the installation is successful
Git
#
Simple configuration of gitosis
After git is installed, we need a server (or git hub to start using GIT)
Git hub has a lot of online information. I will not repeat it here.
Sometimes our development environment is LAN, and the source code does not want others to see it. In this case, we need to build a git server on the LAN.
This article mainly introduces git, but builds an environment to provide simple use and does not introduce gitosis too much.
# Create a git directory
Mkdir /Git
CD/git
# Clone gitosis
GitClone Git: // Eagain.net/gitosis.git
# Install Python Extension
Yum-y install Python-setuptools
# Install
CD gitosis
Python setup. py install
# Generate a Public Key
Ssh-keygen-t rsa-C 'xinxiangmo @ gmail.com'
# Sending the public key to the GIT Server
SCP ~ /. Ssh/id_rsa.pub root@ce.com:/git (ce.com is the IP address of the virtual machine I direct)
# Switch to git server to add and switch users
Adduser git
Su git
# Initialize the version Library
Gitosis-init </git/id_rsa.pub
# Reinitialized existing git repository in/home/git/repositories/gitosis-admin.git/
# Reinitialized existing git repository in/home/git/repositories/gitosis-admin.git/
# Switch to the local machine, clone the repository, and modify and create a project
# (You can directly operate under git server/home/git/repositories/gitosis-admin.git/gitosis. conf)
Git clone git@ce.com: gitosis-admin.git
# Create a project (Name: woyaoquan)
VI gitosis-admin/gitosis. conf
[Group woyaoquan]
Writable = woyaoquan
Members = xinxiangmo@gmail.com
# Switch to the local machine and re-clone
Git clone git@ce.com: woyaoquan. Git
CD woyaoquan & Touch index. php
Git add.# Add a cache
Git commit-M "Submit a file and add the index. php file"
[Master (root-commit) 42e0160] submit the file and add the index. php file.
0 files changed, 0 insertions (+), 0 deletions (-)
"Create mode 100644 index. php"
Git push# Publish to the master Branch
Git + git flow used in the project
Some git parameters have been used above. For details, there are many git parameters.Git Book Pro gitAnd so on. Git itself is flexible.
Git flow is usually used.The version release process is controlled. Due to space issues, the installation of git flow is not shown here, which is also relatively simple.
Briefly describe the project release process
Git flow common bug process:
# Go to the clone repository (the method above) Clone
CD/git/woyaoquan
# Initialize version Process Control
Git checkout-B develop origin/develop
# Initialize the working directory (Press enter all the time)
Git flow init
# Create a new requirement branch.
Git flow feature start editimage # The project automatically switches to the feature/editimage branch.
# After some code is changed
# Git commit-a-m "modified"
# Merge Development branches (automatic)
Git flow feature finish editimage
# Publish to remote Development Branch
Git push origin develop
Git flow emergency bug Process (1)
#Pull back the release version
Git pull origin release/V1.0
#Switch Branch
Git checkout release/V1.0
#Modify bug
#Git commit-a-m "modifying bugs, bug files + lines"
#Submit after modification
Git push origin release/V1.0
Git flow emergency bug Process (2)
# Update master Branch
Git pull origin master (update master branch to the latest)
# Switch to master Branch
Git checkout master
# Generate a hotfix Branch
Git flow hotfix start HFX
# Notify related engineers and testers of the hotfix branch name
# Pull back the latest branch code after the test is complete.
Git pull origin hotfix/HFX
# After the final modification and test are complete, end the hot fix for release.
Git flow hot fix finish HFX
# Final master Branch released
Git push origin master