I don’t understand how it works git grep --cached foo? Running git version 1.6.4.4 or 1.6.5.2 git grep --cached fooreturns the same as git grep foo.
I thought it would work like git diff --cached, just looking for changes in the staging area. This certainly means that the man page makes me believe:
git diff [--options] --cached [<commit>] [--] [<path>…]
This form is designed to view the changes that you have made for the next commit with respect to the name <commit>. Usually you need to compare with the last commit, so if you don't give it <commit>, it will be by default HEAD. If it HEADdoes not exist (for example, non-native branches) and is <commit>not specified, it shows all the phased changes. --stagedis synonymous with --cached.
Is this just a mistake, or is there an alternative / best way to find the changes you need to make to mention foo?
git diff --cached | grep foo
The above command gives me half of what I want, but it loses the context of the file in which the change appears.
UPDATE
It seems I have a concept error for which it is looking --cached. It looks like he is looking for the state of the tree, suggesting that the staging area is applied. It makes sense now that I think about it. What I want to find is the difference, not the complete tree.
, ( ), SpecialLog(...), SpecialLog. , git diff --cached SpecialLog, , , .