从存储库中检索单个文件。
我有10个目录/ somefiles和pom.xml的存储库以及一个名为pom.xml的文件(在目录之外)。所以我需要从该repo中检索带有历史记录的pom.xml。这里有一个问题是pom.xml在所有10个目录中。当我尝试使用git filter-branch -f --prune-empty --index-filter' git rm --cached --ignore-unmatch $ (git ls-files | grep -v" pom.xml“)',此命令检索目录中包含pom.xml的所有pom.xml。可以帮我检索那只pom。 xml不包括目录中的pom.xml。
答案 0 :(得分:1)
git branch just-pom
git filter-branch --index-filter '
git read-tree --empty; git reset $GIT_COMMIT path/to/pom.xml
' -- just-pom --full-history -- path/to/pom.xml
这将保留该文件历史记录的所有内容。在最后一行--
之后的所有内容都是git rev-list
的args,您可以在这里选择哪些提交正好为您正在构建的历史记录提供。