git - 从所有提交中删除旧的别名和电子邮件

标签 git github directory delete-file

我刚刚注意到我的计算机名称和个人电子邮件被用作别名和电子邮件,而不是我的 GitHub 用户名和电子邮件。

有没有办法完全删除 GitHub 上的所有提交以及所有历史记录?

最佳答案

是的,有!见下文。

但是,在这种情况下,您可能还有兴趣在所有提交中仅替换您的姓名和电子邮件地址:https://help.github.com/articles/changing-author-info/


来自how to delete all commit history in github?Make the current commit the only (initial) commit in a Git repository?

这取决于您是否也想删除所有配置。如果这不是问题:

rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin <github-uri>
git push -u --force origin master

您可以先保存.git/config,然后再恢复。


或者,将代码保留在当前状态,但删除之前的所有内容(通过将新分支设为新的“主”分支)

git checkout --orphan latest_branch
git add -A
git commit -am "commit message"
git branch -D master
git branch -m master
git push -f origin master

关于git - 从所有提交中删除旧的别名和电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39664199/

相关文章:

java - 当我输入 "java char *"时,为什么程序引用同一目录中的第一个文件?

Git 多次提交 : Jenkins Pipeline

git - JGit 支持 Webhook 吗?

git 状态(没有提交,工作目录干净),但是已提交更改

php - HTML "link href"如何从不同的文件夹中调用相同的文件?

java - 寻找以前的工作目录来实现 "cd -"

Git-Diff 与 Git-log?有什么不同?

eclipse - 在不使用任何 git eclipse 插件的情况下在 eclipse 中进行开发?

GitHub 找到在 git cli 上找不到的提交

GitHub-API - 获取最新的api版本返回 "Not Found"