Adding deep folders to git

When programming in java, there is usually a file structure with depth

com/company/project/folder/subfolder

Therefore, when adding a file, you must enter

git add com/company/project/folder/subfolder/SomeAwesomeClass.java

Is there a faster way? kind ofgit add-if-matches SomeAwesomeClass.java

+3
source share
4 answers

Try the following command:

git add *AwesomeClass.java

But this will add all files with this name in the current directory or in any of its subdirectories as deep as possible.

If you want to add only a specific file inside a specific directory, you can try:

git add *subfolder/SomeAwesomeClass.java

You can also try the following to add all files to a specific directory:

git add *subfolder/*

Please note that there are no spaces before or after the asterisk symbol.

I tried them on Mac OS X with the exact same script, and it worked.

+1

, git

git add com

, Unix . find - , . git bash, find $()

git add $(find . -name SomeAwesomeClass.java)
+2

git add com, , .

+1

, . bash, .bash_profile

function add(){
    git add $(git status --porcelain | grep "$1" | cut -c 4-)
}

, add something, , , , 2 :

com/company/project/folder/subfoler/AwesomeClass.java
com/company/project/folder/subfoler/subfolder/CoolClass.java

add Awesome

AwesomeClass.java

0

All Articles