github - 如何删除已删除提交的历史记录?
问题描述
我想找到一种方法来删除 github 中剩余的提交历史记录。
我已经派生了一个存储库来做一些工作。我忘了设置名称和电子邮件的配置。
因此,对于第一次提交,它会以不正确的凭据推送。
我通过 rebase 修复它,并且提交被删除。我再次推送,所以我在 git 日志中看不到推送。
但是,第一次推送的历史仍然显示在 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
推荐阅读
- sql - 如何使用 IF EXISTS 修复 SQL 不正确的语法
- angular - Angular 5.2.0:优化大列表渲染
- android - 将数据从存储库传递到 ViewModel
- javascript - 颜色标记定期更换
- node.js - Node.js Mongoose 中的点赞数
- excel - Excel - 聚合:从非空白单元格中提取数据
- angular - 如何自定义数字输入类型单元格 ag-grid
- jquery - DataTable 使用 for 循环添加新行
- java - Laravel 5.2 - 建模器/Laravel-Selenium - 警告 - 抛出异常 java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException
- angular - 回调函数不会调用其类的其他成员函数