Collaborative development using Git Branch
In large-scale software project development, the use of multiple branches can not only develop multi-module tasks in parallel, but also avoid introducing new function code During Bug fixes or accidentally deleting the Bug code to fix and reproduce the problem, clearer development of 'Organizational 'projects.
The new branches generally fall into the following three categories: the release Branch (Bugfix Branch), the feature branch, and the seller branch.
Install Git on Ubuntu Server
Create a Git repository on the server (Ubuntu)
Git simple tutorial in Linux (taking Android as an example)
Git authoritative guide PDF
I. Release Branch
The release branch is mainly used to correct bugs in the Code submitted before, so that the correction process and main line function development can be carried out in parallel.
Ii. Feature branches
Feature branches are mainly used to separate a function module from the Development Main Line, and are suitable for developing function modules with specific features such as long development cycles and experimental features.
Iii. Seller Branch
The so-called seller branch is to create a branch that is synchronized with the upstream in the version library. Once the upstream code is published, it is collected into the seller branch.
Regardless of the Branch, the operation process is nothing more than the following steps:
1. Create a branch (1) You can use
Git branch <newbranch>
Switch to the new branch:
Git checkout newbranch
(2) or directly
Git checkout-d newbranch
By default, it is directed from the latest commit, that is, HEAD, to submit the creation of branch. This method is generally used as a temporary branch. It accepts the changes and is finally deleted after the master branch is merge.
However, in bug modification or new module development, branch needs to be submitted from history, and the commit id or corresponding tag must be added after the preceding statement.
2. Develop on the new branch
Here, you can use git rev-parse to check whether the points of different branches are the same.
The git cherry command can be used to view the current submission ahead of origin.
After the development task on the new branch (the development task can be bug fixing or new module development) is completed, you need to merge the submission on the new branch to the master branch, in general, there are three situations:
(1) Use merge
First, create a new branch and complete the work commit. then switch to the master of the master branch and "merge" the branches created in the master branch. As follows:
Figure 1
Note that you must specify the name of the merged branch after merge.
(2) Use cherry-pick
Figure 6
Switch to the master branch, and then select the newbranch history submission that needs to be merged to the master branch.
This method differs from method (1) in that you can choose to merge newbranch commit instead of all merge.
For more details, please continue to read the highlights on the next page: