GIT Branch Management Policy

Source: Internet
Author: User

Branch management policies

Typically, when merging branches, GIT uses patterns when possible, Fast forward but in this mode, the branch information is discarded after the branch is deleted.

If you want to force the mode to be disabled, Fast forward git will generate a new commit at merge, so you can see the branching information from the branch history.

Here's how we do the actual combat --no-ff git merge :

First, you still create and switch dev branches:

$ git checkout -b devSwitched to a new branch ‘dev‘

Modify the Readme.txt file and submit a new commit:

commit -m "add merge"[dev 6224937] add merge 1 file changed, 1 insertion(+)

Now, we switch back to master :

$ git checkout masterSwitched to branch ‘master‘

To prepare the merge dev branch, note --no-ff The parameter, which indicates disabled Fast forward :

$ git merge --no-ff -m "merge with no-ff" devMerge made by the ‘recursive‘ strategy. readme.txt |    1 + 1 file changed, 1 insertion(+)

Because this merge will create a new commit, add the -m arguments and write the commit description.

After merging, let's take a git log look at the branching history:

$ git log --graph --pretty=oneline --abbrev-commit*   7825a50 merge with no-ff|| * 6224937 add merge|/*   59bc1cb conflict fixed...

As you can see, no pattern is used Fast forward , and the merge is like this:

Branching policy

In the actual development, we should follow several basic principles of branch Management:

First, the master branch should be very stable, that is, only to release the new version, usually do not work on it;

So where do you work? The work is on the dev branch, that dev is, the branch is unstable, to some point, such as the release of 1.0, then the dev branch to merge master , in the master Branch Release 1.0 version;

You and your friends each work on the dev branch, everyone has their own branch, and occasionally merge on the dev branch.

So, the branch of teamwork looks like this:

Summary

The GIT branch is very powerful and should be fully applied in team development.

Merging branches, plus --no-ff parameters can be combined with normal mode, the merged history has branches, you can see that there has been a merger, and the fast forward merger will not be seen to have been merged.

GIT Branch Management Policy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.