如何从拉动请求中删除/清除旧提交历史记录?
在拉取请求并从远程原始分支合并到上游之后,我从远程删除了该分支,但我重命名了本地分支并继续处理它(我认为这就是我搞砸的原因)。当我将此本地分支提交到远程源并向上游发出拉取请求时,我对第一个拉取请求的提交也出现了。
有没有办法从此拉取请求中删除旧的提交历史记录?
或者我必须关闭此拉取请求并将本地分支重新设置为上游,然后再执行另一个拉取请求?
After a pull request and merge from my remote origin branch to upstream, I deleted the branch from my remote, but I rename the local branch and keep working on it (which I think is the reason why I messed up). When I commit this local branch to remote origin and did a pull request to the upstream, my commits of the first pull request also appeared.
Are there ways to remove the old commit history from this pull request?
Or I have to close this pull request and rebase the local branch to the upstream before doing another pull request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您已经从旧分支(此处为 PR 分支)开始工作,请将提交移至上游目标分支(例如原始存储库
main
分支)的顶部,您可以从
快速变基开始:
这给出了:
git push --force ,并且您的新 PR 会以更短的历史记录进行更新。
If you have started working from an old branch (here a PR one), move your commits on top of the upstream target branch (for instance, the original repo
main
branch)You start from
A quick rebase:
That gives:
A
git push --force
and your new PR is updated with a much shorter history.如果您的更改尚未推动,则可以简单地使用
,如果您已经推动了更改,则可以使用此命令
if your changes has not been pushed yet you can simply use
Alternatively, if you have already pushed your changes you can use this command