我刚刚注意到我的计算机名称和个人电子邮件被用作别名和电子邮件,而不是我的 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/