Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How do I recursively add files by a pattern (or glob) located in different directories?

For example, I'd like to add A/B/C/foo.java and D/E/F/bar.java (and several other java files) with one command:

git add '*.java'

Unfortunately, that doesn't work as expected.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
748 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use git add [path]/*.java to add java files from subdirectories,
e.g. git add ./*.java for current directory.

From git add documentation:

Adds content from all *.txt files under Documentation directory and its subdirectories:

$ git add Documentation/*.txt

Note that the asterisk * is quoted from the shell in this example; this lets the command include the files from subdirectories of Documentation/ directory.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...