git checkout only certain file types for entire project

后端 未结 6 1212
遥遥无期
遥遥无期 2020-12-31 05:36

Is there a way to perform a git checkout for only certain file types (.xlf), which recurses down through the entire repository? The results should contain the struture of th

6条回答
  •  無奈伤痛
    2020-12-31 05:44

    You don't need find or sed, you can use wildcards as git understands them (doesn't depend on your shell):

    git checkout -- "*.xml"
    

    The quotes will prevent your shell to expand the command to only files in the current directory before its execution.

    You can also disable shell glob expansion (with bash) :

    set -f
    git checkout -- *.xml
    

    This, of course, will irremediably erase your changes!

提交回复
热议问题