Two ways to merge git code

Source: Internet
Author: User
Tags commit
There are two kinds of git code merging: git merge, Git Rebase, actually the two commands do the same thing, it is to merge one branch into another branch, but its merging way is different.
Git Merge

This merging merges the history of the two branches together, and the existing branch is not changed, it caches the files that are different from each other, generates a commit, and goes to the push

Pros: Secure, existing branches are not modified

Cons: More or less contaminated with a little branching history, it will increase the difficulty of understanding the project history when looking back at the project

Useful: Commonly used for public master main branch git Rebase

This merger is often called "rebase", which is to modify the commit history, than commit to both, and then find out the different caches, then go to push and modify your commit history.

Advantage: Project history will be very neat

Cons: Security and traceability are poor and you won't be able to know that you've made those changes in this merger.

Usefulness: Never use it on a public branch. A summary of the branches that are generally used, themselves alone

Both of these approaches have advantages and disadvantages, and we have to decide which combination to use according to the actual situation and needs. My usage is generally: in my own use of the branch, using rebase, to maintain a good looking project history, in the master Master branch when using the merge, so safe and good tracking changes.


This article was reproduced from: https://www.linuxprobe.com/git-code.html

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.