使用git filter-branch删除除一个子目录之外的所有内容(Using git filter-branch to remove everything except one subdirectory)
我一直在尝试使用git删除除特定分支中的源代码之外的所有内容。 该
git filter-branch -f \ --subdirectory-filter source_code \ --prune-empty \ --tag-name-filter cat -- --all命令基本上得到了我想要的东西,除了它将文件放在source_code/中的根目录,而我希望它们都保留在目录中。 即
- source_code - file1.py - file2.py不只是
- file1.py - file2.py我怎样才能做到这一点?
I have been trying to use git to remove everything except the source code in a particular branch. The
git filter-branch -f \ --subdirectory-filter source_code \ --prune-empty \ --tag-name-filter cat -- --allcommand gets me basically what I want, except it places the files in source_code/ at the root, whereas I want them all to remain in the directory. I.e.
- source_code - file1.py - file2.pynot just
- file1.py - file2.pyHow can I do this?
最满意答案
你需要--tree-filter :
git filter-branch \ --tree-filter "find . -type f -not -wholename './source_code/*' -delete" HEADYou need --tree-filter:
git filter-branch \ --tree-filter "find . -type f -not -wholename './source_code/*' -delete" HEAD
更多推荐
发布评论