我已经阅读了关于从git commit history中删除大型二进制文件的
few
different
threads,但我的问题有点不同.因此,我的问题是要理解并确认步骤 –
我的git repo是〜/ foo.我想从repo中的一个目录中删除所有* .jpg,* .png,* .mp4,* .ogv(等等),特别是〜/ foo / public / data.
步骤1.删除文件
~/foo/data > find -E . -regex ".*\.(jpg|png|mp4|m4v|ogv|webm)" \
-exec git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch {}' \
--prune-empty --tag-name-filter cat -- --all \;
步骤2.将二进制文件扩展名添加到.gitignore并提交.gitignore
~/foo/data > cd ..
~/foo > git add .gitignore
~/foo > git commit -m "added binary files to .gitignore"
第3步.推动一切
~/foo > git push origin master --force
我在正确的轨道上面吗?我想在切一次之前测量两次,所以说.
更新:嗯,上面给了我错误
You need to run this command from the toplevel of the working tree.
You need to run this command from the toplevel of the working tree.
..
所以我把树上升到顶层并重新运行命令,这一切都奏效了.
本文介绍了一种从Git仓库中彻底移除特定目录下所有.jpg,.png,.mp4等大型二进制文件的方法,并更新.gitignore文件以避免未来再次提交此类文件。
1185

被折叠的 条评论
为什么被折叠?



