Git tutorial Learning (iv)

Source: Internet
Author: User

12. Branch Management Scenarios

When working together, it takes a long time to optimize the code x, which can affect the use of the whole code before it is completed. So the finished code can not be submitted to the repository, the submission will affect others to use the overall code. You lose Git's version management feature without committing.

Then you need to branch and branch out the code you're modifying, and others won't see it. And you work on your own branch, and then you end up merging into the original branch.

13. Create and Merge Branches

13.1. Scene

In Git, versioning is a pointer. Each branch has a dedicated pointer. There is also a head pointer pointing to the main version. When implemented, the head pointer actually points to the branch pointer, The branch pointer then points to the branch. Each time a commit is the equivalent of a new branch version. But the different versions of a branch have only one branch pointer.

Creating a new branch is essentially creating a new branch pointer x and pointing the head to the branch pointer so that your changes are on this branch without affecting the modification of major version A.

Merge the branch x with the original version A after the modification is complete

13.2. Create a new branch

$ git checkout-'dev'dev '

13.3. View all branches (where * corresponds to the current version of Head pointing

$ git Branch* Dev  master

When the file is modified, the add commit modifies the new version of the Dev branch. does not affect master

13.4. Switch branches

' Master '

Turning the current branch into a Master,dev still exists

13.5 Merging dev with master

$ git merge devupdating D17efd8. Fec145afast-|    1 1 file 1 insertion (+)

Merges Dev with the repository that the current head points to. Visually this merger is the most recent selection of two branches.

13.6. Delete a branch

$ git branch-d devdeleted Branch Dev (was fec145a).

14.

Git tutorial Learning (iv)

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.