我一直在尝试使用git删除特定分支中除源代码之外的所有内容。的
git filter-branch -f \
--subdirectory-filter source_code \
--prune-empty \
--tag-name-filter cat -- --all
Run Code Online (Sandbox Code Playgroud)
除了将文件放置source_code/在根目录而我希望它们全部保留在目录中之外,命令基本上可以为我提供所需的内容。即
- source_code
- file1.py
- file2.py
Run Code Online (Sandbox Code Playgroud)
不只是
- file1.py
- file2.py
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
您需要--tree-filter:
git filter-branch \
--tree-filter "find . -type f -not -wholename './source_code/*' -delete" HEAD
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
854 次 |
| 最近记录: |