如何安全地在 master 中 git rebase 提交历史记录
我的新团队没有以最有效的方式使用 git,我的领导要求我清理仓库。他们都在 master 下工作——而不是创建分支。 master中有很多小的提交。我创建了一个新分支 bug_rebase_history
并重新调整基础来压缩提交,直到每天有一次提交。这将 master 中的提交从 465 减少到 180。
我如何在 GitLab Web 界面中创建合并请求,以一种不只是在 HEAD 顶部添加新的压缩提交的方式合并此变基?有更安全的方法吗?
My new team has not been using git in the most efficient way and my lead asked me to clean up the repo. They all have been working off of master - not creating branches. There are many small commits in master. I created a new branch bug_rebase_history
and rebased squashing commits until there was one commit per day. This decreased the commits in master from 465 to 180.
How can I create a merge request in the GitLab web interface that will merge this rebase in a way that won't just add the new squashed commits on top of the HEAD? Is there a safer way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是不可能的。
从分支中删除提交的唯一方法是
重置
分支,然后强制将其推回。如果您重写受保护的分支,您将需要从客户端工具中强制推出该分支(并且可能暂时授予自己强制推出受保护分支的权限)。合并(或拉取)请求可以引入(合并)新的提交,但不能从分支中删除任何提交。
It's not possible.
The only way to remove commits from a branch is to
reset
the branch and then force push it back out. If you re-write a protected branch you will need to force push that branch out from a client tool (and perhaps temporarily give yourself permission to force-push the protected branch).A Merge (or Pull) Request can bring (merge) in new commits, but cannot remove any commits from a branch.