Git Merge Confilct
2021-02-20 11:30:21 13 举报
AI智能生成
Git使用中关于代码冲突的处理方法和哲学
作者其他创作
大纲/内容
When
Try to merge
Try to rebase
Try to cherry-picking
Why
Git does not know which code to keep and which to discard.
Each branch only has the differences (the patch concept) from base to new version.
If two branches both modify the same region of a file.
Notes: Not about same line only. It is about same region. So it could be around of the same line.
Notes: Not about same line only. It is about same region. So it could be around of the same line.
The merge conflict does NOT always mean a functional discrepancy.
Re-arrageing the order or the positions of the code can resolve the most conflicts according to our past experience.
For example, "cfg/psudo_tables/spt_rpt.csv". It most happens to configure files.
Re-arrageing the order or the positions of the code can resolve the most conflicts according to our past experience.
For example, "cfg/psudo_tables/spt_rpt.csv". It most happens to configure files.
Core Concepts of Git
"patch" concept
A patch is a small text document containing a delta of changes between two different version of source tree.
Patches are created with the diff program
Notes: In advanced, the user is able to configure use different diff tools. The details check 'git difftool --tool-help'.
Notes: In advanced, the user is able to configure use different diff tools. The details check 'git difftool --tool-help'.
Git is based on patch mechanism to track/manage all commits and merge actions.
Resolve Merge Conflict Means
(For example, Branch A conflicts to Branch B)
(For example, Branch A conflicts to Branch B)
Keep the version of code from Branch A
Keep the vesrion of code from Branch B
Keep both codes from Branch A and B
Need to combine/rewrite both logical in Branch A and B
Need to combine/rewrite both logical in Branch A and B
Keep In Mind in Practice
!!! Need to 100% fully understand the changes in BOTH Branch A AND Branch B !!!
Any Not-understood piece can cause the missing/failure on functionality while no compiling issue and/or error messages. And the issue can be hard to aware or find.
Any Not-understood piece can cause the missing/failure on functionality while no compiling issue and/or error messages. And the issue can be hard to aware or find.
Raise the flag or ask original developer for help if having any unclear pieces
Add and Test the test cases which cover both Branch A and Branch B.
If Branch A goes to PROD prior to Branch B, please request at least one day isolated testing in UAT environment in case
0 条评论
下一页