How does GIT delete an intermediate incorrect commit and keep the subsequent correct commits?
phpcn_u15822017-05-02 09:32:27
0
5
766
As shown in the title, there is an incorrect commit in the middle, and then there are a bunch of correct commits. Now I want to delete this error and keep the correct ones. How to do it?
The normal approach is to rebase and process subsequent commits manually (resubmit all useful commits, ignore useless commits, and merge redundant commits). The risks and difficulties are relatively high. (Repair the situation, save the sheep and kill the wolf)
The lazy way is to go back to before the wrong commit, and then resubmit with a new branch. This is safe, but the workload will be relatively large, and it is easy to make mistakes in the middle. (Repair the sheep’s fold, mend the sheepfold and save the sheep)
It’s even more lazy to commit a new submission later to correct the previous error. (Repair the lost sheep, mend the sheepfold and buy a new sheep)
git rebase -i returns to a previous version containing the wrong submission. There is an option to abandon a certain submission. Please refer to Baidu for specific usage
It doesn’t seem to work, unless you RESET back to the previous submission, then delete the subsequent submission log, and then resubmit what you need. I checked before.
The normal approach is to rebase and process subsequent commits manually (resubmit all useful commits, ignore useless commits, and merge redundant commits). The risks and difficulties are relatively high. (Repair the situation, save the sheep and kill the wolf)
The lazy way is to go back to before the wrong commit, and then resubmit with a new branch. This is safe, but the workload will be relatively large, and it is easy to make mistakes in the middle. (Repair the sheep’s fold, mend the sheepfold and save the sheep)
It’s even more lazy to commit a new submission later to correct the previous error. (Repair the lost sheep, mend the sheepfold and buy a new sheep)
git revert wrong_commit
git rebase -i returns to a previous version containing the wrong submission. There is an option to abandon a certain submission. Please refer to Baidu for specific usage
I don’t know if you are asking about commit --amend...
It doesn’t seem to work, unless you RESET back to the previous submission, then delete the subsequent submission log, and then resubmit what you need. I checked before.