Is there a way to use wildcards with git checkout?

前端 未结 8 913
遇见更好的自我
遇见更好的自我 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:03

    Knowing that git returns branch list names from 3rd char, one can just switch to needed branch defined via [mask]:

    BRANCH_NAME=$(git branch --list | grep [mask] | cut -c3-)
    git checkout ${BRANCH_NAME}
    

提交回复
热议问题