如何编辑过去的 git 提交以从提交日志中删除我的密码?
我的问题:使用 https:// URL 时,cygwin git 似乎没有正确提示输入凭据,因此我在 URL 中使用了用户名和密码。不幸的是,当我执行“get pull”时,它会自动提交一条包含完整 URL(包括密码)的消息。直到我推送更改后我才注意到这一点。
如何编辑旧的提交消息以消除 URL 中的密码?
我的共享 git 存储库位于我自己的服务器上。如有必要,我可以对回购进行手术。
关于如何更改我的配置(即不使用 Cygwin,不使用 https)的说明是不必要的——我正在尝试处理已经完成的事情。
是的,我可以并且将会烧掉密码,但我仍然想修复它。
My problem: cygwin git doesn't seem to correctly prompt for credentials when using https:// URLs, so I used username and password in the URL. Unfortunately when I did a "get pull" it auto-commited a message with the full URL including password. I didn't notice this until after I had pushed the changes.
How do I edit old commit messages to eradicate the password in the URL?
My shared git repo is on my own server. I can do surgery on the repo if necessary.
Instructions on how to change my configuration (i.e. don't use Cygwin, don't use https) are unnecessary -- I'm trying to deal with what is already done.
Yes, I can and will burn the password but I'd still like to fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要从 git 存储库及其历史记录中完全删除文件,请使用以下命令。
有关详细信息,GitHub 上的删除敏感数据指南将为您提供帮助。
To completely remove a file from a git repository and its history, use these commands.
For more information, remove sensitive data guide at GitHub will help you.
删除 git-hub 上的敏感数据的链接很有用。然而,我发现了一个非常易于使用的工具:Eric Raymond reposurgeon。
这个工具允许我轻松导入我的存储库,列出有问题的提交,编辑它们(我单独这样做)并写出我的存储库的 git 快速导入流。我将该流导入到一个新的存储库中,并将其同步到位。
缺点是我的旧仓库完全死了——我改变了历史。根据文档,使用“git filter-branch”也是如此。
The link to removing sensitive data on git-hub is useful. However, I found a tool that was very straight-foward to use: Eric Raymond reposurgeon.
This tool allowed me to easily import my repo, list the commits with the issue, edit them (I did so individually) and write out a git fast-import stream of my repo. I imported that stream into a new repo and rsync'd it into place.
The downside is that my old repo is completely dead -- I changed history. That would be true of using "git filter-branch" as well, according to the docs.
如果您可以编辑服务器,则可以将分支头重置为前一个(HEAD^)。
就这样。顺便说一句,在执行上述操作之前,您无法更改拉取的存储库
If you can edit the server, you can reset branch head to the previous one (HEAD^).
that's all. BTW, you cannot change the repo pulled before you did the above