首页 > 解决方案 > 如何删除已删除提交的历史记录?

问题描述

我想找到一种方法来删除 github 中剩余的提交历史记录。

我已经派生了一个存储库来做一些工作。我忘了设置名称和电子邮件的配置。

因此,对于第一次提交,它会以不正确的凭据推送。

我通过 rebase 修复它,并且提交被删除。我再次推送,所以我在 git 日志中看不到推送。

但是,第一次推送的历史仍然显示在 github 中。这是因为我参考了分叉存储库的问题编号。

有没有办法从 github 中删除该历史记录?

标签: github

解决方案


以下是有关如何从此链接清除历史记录的建议:

-- Remove the history from 
rm -rf .git

-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"

-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
git push -u --force origin master

推荐阅读