“git add” using wildcard is not functioning as I hoped - must I cd into specific directories?

后端 未结 3 2073
粉色の甜心
粉色の甜心 2020-12-24 10:58

When I try to do a basic git add *.erb (or any simple wildcard expressions) git is not recognizing it (them). As a side-note, I have never done this before so I

3条回答
  •  天命终不由人
    2020-12-24 11:16

    I can't get recursive globs to work for me as my version of bash is too old. So what I do is

    find . -name "*.rb" | xargs git add
    

    Works a treat and I can add other filters there if I need - so if I want to add all but one file I can do this.

    find . -name "*.rb" | grep -v "not_me.rb" | xargs git add
    

    There's a couple of other cases that can be useful.

    If you just want to add files that already exist in your repo you can

    git add -u .
    

    If you want to add every thing then

    git add .
    

提交回复
热议问题