【发布时间】:2022-01-03 19:07:28
【问题描述】:
我想修改当前的 git commit 并删除它以前的形式。换句话说,“旧”当前提交必须消失,并被具有相同提交消息的“新”提交所取代。
目前我正在做:
git add .
git commit --amend --no-edit
git push --force
从网络界面(gitlab)或使用git log,我只能看到“新”当前提交;但如果我搜索“旧”当前提交哈希(网络界面或.git),我仍然能够看到“旧”提交内容。
有没有办法完全删除旧的“当前”提交?
谢谢
更新
遵循我尝试过的一些建议:
git add .
git commit --amend --no-edit
git stash clear
git fsck --unreachable --no-reflogs
git reflog expire --expire-unreachable=now --all
git gc --prune=now
git repack
git push --force
虽然在本地我可以看到提交不再存在 (git branch -a --contains <commit_id>),但 gitlab 上的存储库大小继续增加,即使我触发了内务处理。
【问题讨论】:
标签: git gitlab git-commit git-revert git-amend