一位同事做了一些我告诉他们不要做的事情:
- 在线分叉原始仓库
- 克隆了 fork,添加了一个不应该添加到该本地 repo 的文件
- 把这个推到他们的叉子上
我当时:
- 合并来自 fork 的更改并找到文件
我想从以下内容中删除它:
- 我的本地仓库
- 叉子
- 他们的本地仓库
我有一个从历史记录中删除某些内容的解决方案,取自Remove file from git repository (history)。我需要知道的是,我的同事是否也应该经历这个,随后的推送会从分叉中删除所有信息吗?(我想要一个替代方法来破坏叉子,因为我不确定我的同事会这样做)
SOLUTION: This is the shortest way to get rid of the files:
check .git/packed-refs - my problem was that I had there a refs/remotes/origin/master line for a remote repository, delete it, otherwise git won't remove those files
(optional) git verify-pack -v .git/objects/pack/#{pack-name}.idx | sort -k 3 -n | tail -5 - to check for the largest files
(optional) git rev-list --objects --all | grep a0d770a97ff0fac0be1d777b32cc67fe69eb9a98 - to check what files those are
git filter-branch --index-filter 'git rm --cached --ignore-unmatch file_names' - to remove the file from all revisions
rm -rf .git/refs/original/ - to remove git's backup
git reflog expire --all --expire='0 days' - to expire all the loose objects
(optional) git fsck --full --unreachable - to check if there are any loose objects
git repack -A -d - repacking the pack
git prune - to finally remove those objects