Git automatically merges code. Is it possible that a bug will occur in the merge?
迷茫
迷茫 2017-06-17 09:15:34
0
9
1283

I had thought about this problem before when I was using SVN, but I didn’t understand it at the time and I didn’t encounter any bugs.
Now that I am learning Git, I have the same question, so I raised it.

Question:
When merging branches, if there are no conflicts, will the code automatically merged by Git have bugs?
Because the conflicts detected by Git during merging are all editing conflicts, such as whether the two edits are on the same line, and whether the two edits have opposite operations (one adds and one deletes the same code), obviously, Git It does not and cannot care about the logic of the code itself.
So I think you should check the correctness of the code after merging, which is equivalent to verifying after each merge whether the problems solved by the two branches are in an unresolved state after the merge, and whether new bugs have been generated. , then the workload will be too much, right?
I wonder if you would check this in actual use?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (9)
淡淡烟草味

If you have Baidu, you should see similar information: Although your development is on branch, in order to ensure that it does not deviate too far from the trunk, you need to merge it from trunk to branch frequently.

If a team follows the process, there won’t be much of a problem.

    学习ing

    If multiple people edit the same code, Git will report a merge conflict, which needs to be resolved manually. Git has no way of knowing how to handle these codes, which is unavoidable. In actual multi-person collaboration projects, everyone usually develops in modules and tries to avoid changing the same files; update the common modules before changing them.

    If no conflicts are reported after the merge, it means that the same code has not been changed much, and there is no need to check the correctness of the merge. As for the merged code that introduces logical bugs, it needs to be reviewed.

      phpcn_u1582

      Of course you can. A function needs to use three methods a b c. Three people should change those three methods (assuming that none of the three people know that others have changed it); in this case, git will not consider it a conflict; But can you still ensure that this function is still what the three of them want?

        过去多啦不再A梦

        No, because there are two situations in git merge. First: in a file, the same piece of code has been modified by two people at the same time, and git merge will report a conflict. Manual merging is required. Second: If two people change different code segments of the same file. git will merge automatically. Whether or not there are bugs is entirely the problem of the person who wrote the code. There are bugs, and there will naturally be bugs after the merger. There are no bugs, and there will be no bugs after the merge. Don't blame others!

          三叔

          Git was shot while I was lying down. I burst into tears and said: I am only responsible for code merging. Bugs are written by people. I will not bear the blame. . . . . .

            typecho

            Nothing is absolute. If there is no conflict and a bug can be merged, it can only be said that you have won the prize

              给我你的怀抱

              This is not called a bug, it is called aconflict. Conflict resolution:

              1. Use someone else’s version

              2. Use your own version

              3. Manual merge.

              A very common way to avoid conflicts is: before modification, firstpullthe local branch to reduce the chance of conflicts

                刘奇

                Well, git is just a version management tool. If you merge the code and a bug occurs, it is a problem with your project team's own code. It is not git's fault at all. Your problem should be solved by writing test code.

                  为情所困

                  It is possible, it is equivalent to winning a lottery

                    Latest Downloads
                    More>
                    Web Effects
                    Website Source Code
                    Website Materials
                    Front End Template
                    About us Disclaimer Sitemap
                    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!