For example, if you have a bug in your dev folder and want to revert to git reset, you can revert it with Git revert. For example, if you have a bug in your dev folder and want to revert to Git reset, you can revert with Git revert. Reset reverses a commitID commit, the added file is deleted, the changes are restored, and a new commit is created on the master. Reset reverses the commit, and the new commit is created on the master.

However, with Git revert you need to be aware of the following direct examples

  • 1. The merge dev to master
  • 2. After some time, IN C4, I suddenly found that there was a problem with the M1 code that was merged into master dev. At this time, I reverted M1 on Master dev and created a new commit W1 on Master dev
  • 3. Well, since the problem is dev, switch back to dev for several versions (c, D) of development, fix the previous bug
  • 4. Merge dev code into master after fixing bug, but the problem is that M2 merge code does not include a and B on dev branch. When git merges code from a branch, only commits that have not been merged before will be merged. As shown in the figure, Git determines that the two commits of A and B have been merged in M1, so when M2 merges, only the two commits of C and D will be merged in master. A and B commits will be lost when M2 merges dev into master.

So how do we solve this

Solution a: Git merge Dev merges the latest update to add to the list of m1-related changes that W1 has already deleted. This allows you to merge the latest update to add to the list of m1-related changes

Scheme 2: In dev after fix the bug, dev first to master to rebase (rebase), because after the rebase, a, b two commitID submitted, has been and M1 merge into master commitID different, at this time to perform the git merge dev, Git will merge all dev code into master if a, B,c,d commitID does not appear on dev

After dev fixes the bug, use cherry pick to manually merge the code of A, B, C, and D on dev to the master to form 4 new commits. This will not lose the changes of A and B.