“git add *.js” did not add the files in sub-directories

后端 未结 3 1640
被撕碎了的回忆
被撕碎了的回忆 2021-02-20 02:00

Was trying to commit some changes. I used git add to add any new javascript files that I may have created using the wildcard *.js. Then I committed cha

相关标签:
3条回答
  • 2021-02-20 02:58

    An alternative is to use the find command:

    find . -name '*js' -exec git add {} \;
    

    Running that without the exec will give you the list of files that you are working on; so, it is easy to tune this command to your liking.

    0 讨论(0)
  • 2021-02-20 02:59

    You need to use

    git add '*.js'
    

    You have to use quotes so git receives the wildcard before your shell does. If you do not have quotes the shell will only do the wildcard search within your current directory.

    0 讨论(0)
  • 2021-02-20 03:00

    even though I had just added them using the wildcard: git add *.js

    Shell wildcard expansion does not recurse into subdirectories. The wildcard is expanded before Git gets a chance to see it.

    If you use git add '*.js', then Git will see the wildcard and will match it against all path names that end in .js. Because the * is in the initial position, this will end up recursively adding all .js files including in subdirectories.

    0 讨论(0)
提交回复
热议问题