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'm sure it's a rookie mistake, but I've found no help in other SO posts or my school's alumni listserv so I thought this post may be appropriate.
For (a different) example, git status is giving me:
# modified: config/routes.rb
# modified: spec/models/question_spec.rb
I wanted to only stage the routes file, so I tried git add *s.rb and no dice. I am in the root of the app...do I need to be in the directory that contains the file(s) I'm trying to apply the wildcard expression to? That would be painful, but...actually...it just worked.
Hope this doesn't have to be a separate post, but is there an easier way to use wildcards where you don't have to cd into the specific directory?
zsh
), I typegit add *.cpp<TAB>
, and the shell completes the wildcard to the full filenames.git add **/*.cpp<TAB>
does allcpp
files under the current dir. Bash may have something similar.**
for recursive globbing (wiki.bash-hackers.org/syntax/expansion/globs), so if you're using a recent enough version of bash,git add **/*.rb
should do what you want.git add **/*s.rb
and am all good!git add */*s.rb
as well and was successful. Does the*/
act as a wildcard for one directory deeper, but**/
denote recursive infinite directories? If I should ask a new question, let me know!*/*s.rb
will match everything ending "s.rb" one directory deep (and not in the current directory and not deeper). Similarly*/*/*s.rb
would be everything ending "s.rb" two directories deep, but nowhere else (deeper or shallower).