Git code multiple people write the same page or function, merge code conflict

when multiple people develop the same page or function, there will be an inexplicable bug

when merging the code. In such cases as

and so on, this kind of merger will not report an error, so it will be merged directly, resulting in sometimes not knowing what went wrong and uncoordinated development by many people.
pull and submit code using the git bash command line, not graphical tools, so how to solve and avoid this situation, ask for advice.

Mar.22,2021

recommend git tools in ide

  • first step: select the file to submit, and then click commit
  • part 2: first pull the remote code to the local. In this step, ide will automatically stash, small conflicts and automatically merge, large conflict popups
  • part III Direct push

saves time and effort


you can try to compare the differences between branches.
check that the dev branch submitted more content than master:

git log master..dev

you can also compare the differences between different commit:

git diff COMMIT1 ^ COMMIT2

  1. when merging, use visualization tools such as, github Desktop or sourceTree to view the merged code, you can clearly see where your changes are, make sure that your changes do not affect the functions of others, and you should be responsible for your own code.
  2. if it's the merged person, it's best to run through the merged code to see if there are any obvious exceptions;
  3. and there is a need for certain specifications within the team, such as writing CSS globally, which can easily affect other people's code, and there are limits to what tools can do, which is more reliable by individual control and team specifications.

first of all, conflicts can be resolved manually. There are a lot of specific methods, which have been explained by the boss above.

what I want to emphasize is that for code like your screenshot, I just ask, how do you merge manually? Do two people use the same className or do two different things happen to have the same name? Are you going to check the logic? If it's been a few days. Do you still have to look at the code? So this is a matter of teamwork, before changing to public, be sure to see whether others use it or not. It just proves that neither of you looked at it and only took care of your own code.

tell me what to do:
first of all, it is best to have a special person in charge of the public area. If another person wants to change or add, tell the person in charge that the person who wants to add functionality can write it, but the merging code must be decided by the person in charge.
secondly, different people do different functions, and different functions are divided by different files. Use modular programming (which is not detailed here). In this way, even if the naming conflicts. But it won't affect each other.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5b0db-44575.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5b0db-44575.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?