How to checkout files from branch with wildcard path spec?

后端 未结 1 1959
野的像风
野的像风 2021-01-26 12:50

I\'m unable to checkout files using wildcards, as described on the git-scm page, from a specific refspec . Describing the issue with an example.

Creating a repository wi

相关标签:
1条回答
  • 2021-01-26 13:43

    As far as I can tell, when you do git checkout d62e124f -- '*.java', git uses the current working tree to expand *.java, not d62e124f. As you have just deleted all the files, it matches nothing.

    Doing

    git restore --source d62e124f '*.java'
    

    works, as git then uses the correct ref to expand the wildcard.

    git restore is only available since 2.23.0, before that you can use:

    git ls-files d62e124f '*.java' | xargs git checkout d62e124f
    
    0 讨论(0)
提交回复
热议问题