如果作者都是你,并且你不需要保留受影响提交的日期(所有这些,AE),那几乎是微不足道的,另一种方式将需要更多
根据您的图片,我将在错误之前添加修订 F 作为提交。假设你在分支'master'上,
git log --oneline master~6..master
应该向您展示这些修订。
git branch corrected master~5 # this is F, master~0 is A i.e. the branch tip
git config advice.detachedhead false # just to get it to stop blabbing at you
# make corrected commit E
git checkout master~4
git rm --cached yourconfigfile
echo ref: refs/heads/corrected >.git/HEAD
git cat-file -p master~4 | sed 1,/^$/d | git commit -m-
# make corrected commit D
git checkout master~3
git rm --cached yourconfigfile
echo ref: refs/heads/corrected >.git/HEAD
git cat-file -p master~3 | sed 1,/^$/d | git commit -m-
# ... repeat for C, B, and A
在末尾,
echo ref: refs/heads/master > .git/config
你就完成了。保留作者/日期信息是从标题中设置 GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL,DATE} 向git cat-file -p
您显示的问题,如果您需要它,我会为您准备一个 sed。