The command to accomplish that is:
git rebase -i HEAD~7
This will open up your editor with something like this:
pick f392171 Removed most clearfixs in templates
pick ba9dd9a Removed most clearfixs in templates
pick df71a27 Unew redirect logic
pick 79ce782 Merge branch 'develop' of github.com:xxx/xxx into develop
pick 1383070 Merge branch 'develop' of github.com:xxx/xxx into develop
...
Now you can tell git what to do with each commit. Let's keep the commit f392171, the one where we added our feature. We'll squash the following two commits into the first one - leaving us with one clean.
Change your file to this:
pick f392171 Removed most clearfixs in templates
squash ba9dd9a Removed most clearfixs in templates
pick df71a27 Unew redirect logic
pick 79ce782 Merge branch 'develop' of github.com:xxx/xxx into develop
squash 1383070 Merge branch 'develop' of github.com:xxx/xxx into develop
When you save and exit the editor, Git applies all two changes and then puts you back into the editor to merge the three commit messages:
# This is a combination of commits.
# The first commit's message is:
Removed most clearfixs in templates
# This is the 2nd commit message:
Removed most clearfixs in templates
When done, save and quit your editor. Git will now squash the commits into one. All done!
Then you have to do
git push origin your-branch -f
to force your locally commits changes into remote branch.
Note: You have to do a squash to every duplicated commit.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…