pun*_*ish 9 git git-rewrite-history
我从git commit history中删除了大量二进制文件的几个 不同的 线程,但我的问题有点不同.因此,我在这里要了解并确认步骤 -
我的git回购是~/foo.我想从repo中的一个目录中删除所有*.jpg,*.png,*.mp4,*.ogv(等等),特别是从~/foo/public/data.
~/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 \;
Run Code Online (Sandbox Code Playgroud)
~/foo/data > cd ..
~/foo > git add .gitignore
~/foo > git commit -m "added binary files to .gitignore"
Run Code Online (Sandbox Code Playgroud)
~/foo > git push origin master --force
Run Code Online (Sandbox Code Playgroud)
我在正确的轨道上面吗?我想在切割一次之前测量两次,所以说.
更新:嗯,上面给我的错误
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.
..
Run Code Online (Sandbox Code Playgroud)
所以我把树上升到顶层并重新运行命令,这一切都奏效了.
这个过程似乎是对的.
你也可以用一个测试你的清洁工艺像BFG回购清洁工具,在这个答案:
java -jar bfg.jar --delete-files *.{jpg,png,mp4,m4v,ogv,webm} ${bare-repo-dir};
Run Code Online (Sandbox Code Playgroud)
(除非BFG确保它不会删除最新提交中的任何内容,因此您需要删除当前索引中的那些文件并进行"干净"提交.所有其他先前的提交将由BFG清除)
| 归档时间: |
|
| 查看次数: |
6152 次 |
| 最近记录: |