Git error commit

Git is a tool that programmers usually use in addition to the compiler. Whether using native Git instructions or source tree, fork or other Git tools, there may be errors in the submission situation. Do not be in a hurry at this time. Here are three solutions and ideas (I mainly use Fork) :

Never, ever use Revert!!!!!

To revert means to revert your code back to the state before the commit. However, because Git only recognizes the SHA value of the commit when merging, it does not compare code differences, which can result in code being lost. For example, IF I merge branch A to BRANCH B by mistake and want to revert this commit, don’t do it!! When YOU merge branch B again, you will find that all the revert code is missing because git only compares commit SHA values. There is no comparison between Branch A and Branch B code, even if you already revert it.

usegit rebase

If I merge branch A into the master branch by mistake, do not revert. This can cause confusion in your master branch. Instead, reset your master branch to where it was before the error commit. That way, your master branch is clean, and it doesn’t affect anyone else’s ability to create new branches on the Master branch.

usegit cherry-pick commit

If you have submitted the wrong code to your feature and cannot revert, what else can you do? The best way to do this is to create a new feature-2, cherry-pick feature that you want to commit, so you don’t have to revert, and the sha value of the new branch will be different, so there is no code missing, so you have to completely rewrite the code

The above is the author’s superficial understanding, it is my greatest honor to help you, if there is any mistake, welcome to point out in the comment section.