Правильно ли это поведение git для «git add» с подпапками?

When using "git add" with a file pattern it only adds recursively the untracked files, and ignores the changed ones unless they are in the current folder.

Example:

$ git status
# On branch master
# Changed but not updated:
#    (use "git add ..." to update what will be committed)
#    (use "git checkout -- ..." to discard changes in working directory)
#
#       modified:    level1/test1.txt
#       modified:    level1/level2/test1.txt
#
# Untracked files:
#   (use "git add ..." to incldude in what will be committed)
# 
#       level1/test2.txt
#       level1/level2/test2.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git add level1\*.txt
$ git status
# On branch master
# Changes to be committed:
#       new file:   level1/level2/test2.txt
#       new file:   level1/test2.txt
#
# Changed but not updated:
#       modified:   level1/level2/test1.txt
#       modified:   level1/test1.txt
#

After I execute git add level1\*.txt, the untracked (test2.txt) files are added, but not the modified (test1.txt) files. I've tried with the -u option, escaping and not escaping the asterisk, etc. but nothing seems to simply be able to add ALL files matching a pattern whether they are tracked or not.

Of course in this example I could just add all the files with -A, but keep in mind this is just for the purpose of this question, in reality there will be more files and I would not want to add them all, and the hierarchy is a few folders deeper. The only way for me to add the tracked files is referring to the directing or writing the whole pattern except for the file name like this: git add level1**.txt OR git add level1/level2/*.txt.

In the git add documentation: here it says that the file pattern is supposed to work recursively and doesn't say anything about tracked or untracked files and it even gives and example.

I'm using msysgit but I've tested this on Windows and Linux just in case.

I just want to know. Am I interpreting the documentation correctly (because I think based on the docs it should work) or is this how it is supposed to work? It just doesn't make sense to me.

6
задан Cascabel 10 November 2010 в 15:52
поделиться