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