Reputation: 20909
I have a file down deep in my git tree:
$ git ls-files | grep /Expression.java
sm/src/main/java/cl/utilities/sm/Expression.java
I'd like to get a log of its activity without having to type the whole path. Basically I want this output:
$ git log --oneline -2 sm/src/main/java/cl/utilities/sm/Expression.java
2718cdc cleaned up some warnings
f30cf15 Added missing @Overrides
... but without having to type sm/src/main/java/cl/utilities/sm
. I tried lots of things, but none of them worked:
$ git log -- \*/Expression.java
$ git log -- \*Expression.java
$ git log -- \*\*/Expression.java
$ git log -- '*/Expression.java'
$ git log -- '**/Expression.java'
Upvotes: 13
Views: 5203
Reputation: 1324053
With git 2.8 (March 2016), wildcards are more firmly supported both as pathspec or refspec.
See commit aac4fac, commit df714f8, commit 1cc777d (10 Feb 2016) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit e6a6a76, 24 Feb 2016)
That means that:
wilcard works with pathspecs:
git log -- "*.t"
# or
git log "*.t"
wildcard works with refspecs (when searching for a commit message starting with 'b
' for instance):
git log "HEAD^{/b.*}" --
# or
git log "HEAD^{/b.*}
Upvotes: 3
Reputation: 8708
Use a wildcard, no escapes or quotes required:
git log -- */Expression.java
Tested on Windows 7 in cmd shell and git bash.
Depending on your shell, you may need quotes -- if single quotes don't work, try double quotes.
Upvotes: 8
Reputation: 22972
use xargs
:
find . -name 'Expression.java' | xargs git log --oneline -2
Upvotes: 3