git: How do I recursively add all files in a directory subtree that match a glob pattern?

后端 未结 6 1984
谎友^
谎友^ 2021-01-31 14:15

I have several .screen files inside /xxx/documentation and its subdirectories that are already tracked by Git.

After modifying many of these screen files, I

6条回答
  •  野的像风
    2021-01-31 14:22

    This what I just used for a similar problem of git adding all the files in a directory:

    find . | sed "s/\(.*\)/\"\1\"/g" | xargs git add 
    

    For the original question the command would be:

    find -name "*.screen" | sed "s/\(.*\)/\"\1\"/g" | xargs git add 
    

    Note that I'm dealing with the case where a fully specified file name contains spaces. Thats why my answer. Edit the portion before the first | in order to pick out different files to add.

提交回复
热议问题