在将一个分支重新建立到另一个分支上后,我遇到了一个有趣的问题;git rebase -i HEAD~n不仅显示错误的提交历史记录(旧分支),还显示错误的提交数量。
我希望能够对git rebase -i HEAD~n正确的提交历史记录进行操作,以便压缩我基于分支的旧分支的剩余提交。
# On another Feature branch
git branch -b NewFeautureBranch
# Develop my commit
git add editedfile.extension
git commit -m "Commit message"
# I squashed and merged the feature branch into the development branch, as well as some other feature branches
git fetch --all
git checkout DevelopmentBranch
git pull
git checkout NewFeatureBranch
git rebase DevelopmentBranch
git push -f
Run Code Online (Sandbox Code Playgroud)
运行git log并gitk会显示应有的历史记录,这是我当前的提交和它最初基于的功能分支的较旧提交,如预期的那样。然而,如果我随后运行,git rebase -i …