git rebase -i HEAD~99 Then change the picks in front of the 10 furthest commits to squash. Then force commit git push -f Try it, I don’t know if it works
The method mentioned above is correct, but it should be git rebase -i HEAD~100 吧。HEAD~99 It can only read 2 to 100 submissions, but not the first one.
In addition, after finding the 10 furthest commits, you don’t actually have to change it to squash (or s). If you don’t plan to keep the commit information, just use fixup (or f). .
It must be git push -f after modification, because your timeline and subsequent commit hash have changed, of course your code will not change
Since it may take a long time to scroll from the last one to the first one. . Provide another idea (hereinafter, <xxx> is used to represent variables, and there is no need to type < and >. But other symbols must be typed):
Create a new branch based on the current branch: git checkout -b newBranch
Roll back to before the first commit on a new branch: git reset --hard <commit1Hash>
Cherry pick the first ten commits and put them in the buffer: git cherry-pick -n <commit1Hash>..<commit10Hash>
Submit these ten commits. git commit -m "<xxxx>"
Cherry pick remaining commits, not placed in buffer (directly added to timeline): git cherry-pick -n <commit11Hash>..<commit100Hash>
In this way, you have done what you want on a new branch. Just merge it into the branch you want to modify
git rebase -i HEAD~99
Then change the picks in front of the 10 furthest commits to squash.
Then force commit git push -f
Try it, I don’t know if it works
The method mentioned above is correct, but it should be
git rebase -i HEAD~100
吧。HEAD~99
It can only read 2 to 100 submissions, but not the first one.In addition, after finding the 10 furthest commits, you don’t actually have to change it to squash (or s). If you don’t plan to keep the commit information, just use fixup (or f). .
It must be
git push -f
after modification, because your timeline and subsequent commit hash have changed, of course your code will not changeSince it may take a long time to scroll from the last one to the first one. . Provide another idea (hereinafter, <xxx> is used to represent variables, and there is no need to type < and >. But other symbols must be typed):
Create a new branch based on the current branch:
git checkout -b newBranch
Roll back to before the first commit on a new branch:
git reset --hard <commit1Hash>
Cherry pick the first ten commits and put them in the buffer:
git cherry-pick -n <commit1Hash>..<commit10Hash>
Submit these ten commits.
git commit -m "<xxxx>"
Cherry pick remaining commits, not placed in buffer (directly added to timeline):
git cherry-pick -n <commit11Hash>..<commit100Hash>
In this way, you have done what you want on a new branch. Just merge it into the branch you want to modify