git - 如何从 pull 请求中删除与用户一起提交的用户?

标签 git github

fork 了一个存储库。进行了处理,然后提交了我的 pull 请求。然而,存储库所有者希望提交被压缩。在压缩提交时,我遇到了许多 merge 冲突。压缩所有提交后,现在我的 PR 显示“用户 B 与用户 A 一起提交”,其中 用户 B其他人用户A。我如何删除“用户 A 与用户 B 提交”?我怎样才能让公关只展示我的 promise ,而不是把其他人的 promise 结合起来?我尝试了堆栈溢出的各种答案。这个Removing <user> committed with <user> on Github可能适用于本地提交。但我已经把一切都推了。 请帮忙。

最佳答案

使用git filter-branch更改作者和提交者。

复制以下脚本并替换以下内容:

  • 012345:提交编号
  • 此处的姓名:您的姓名(出现 2 次)
  • [email protected]:您的电子邮件(出现 2 次)

git filter-branch --env-filter \
'if test "$GIT_COMMIT" = "012345"; then
    export GIT_AUTHOR_NAME="Name Here"
    export GIT_COMMITTER_NAME="Name Here"
    export GIT_AUTHOR_EMAIL="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="791c1418101539111c0b1c571a1614" rel="noreferrer noopener nofollow">[email protected]</a>"
    export GIT_COMMITTER_EMAIL="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4e2b232f27220e262b3c2b602d2123" rel="noreferrer noopener nofollow">[email protected]</a>"
fi' && rm -fr "$(git rev-parse --git-dir)/refs/original/"

小心:它会重写历史记录,如果你已经推送了,你可能必须使用git push --force

关于git - 如何从 pull 请求中删除与用户一起提交的用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46358948/

相关文章:

git - PyCharm,git : Cannot Pull after remote repo name changing

windows - 在 git 中使用具有相同名称但在 Windows 中大小写不同的目录

github - Git流命令错误: 'flow' is not a git command

git push 在 gitlab 中失败

ruby - 检查GitLab API访问: FAILED.代码:404

git - Azure DevOps - 将 master 分支与过去的 master 分支进行比较

git - 我如何处理 Git 存储库中的图像?

git - 单击 'merge pull request' 按钮运行自动测试

Git:在另一个分支工作时修复主分支中的错误

git - git add -n --ignore-missing 实际上做了什么?