Is there a way to use wildcards with git checkout?

前端 未结 8 852
遇见更好的自我
遇见更好的自我 2020-12-24 00:40

What I would like to do is to checkout a single file or a set of files with a common name part like this

git checkout myBranch */myFile.md and

<

8条回答
  •  囚心锁ツ
    2020-12-24 01:08

    Powershell

    @(gci -Recurse *test* | Resolve-Path -Relative) | %{git checkout mybranch -- $_)
    

    gci generates a list of all files matching the criteria (*test*) then pipes it to Resolve-Path to get the relative path. Finally the flattened (@) list of filenames is piped into the git invokation (executes once per file found).

提交回复
热议问题