Listing one or more files under Git version control
I just had to locate swap files that someone had mistakenly checked in over the course of the last 30 commits, and figured there was a way to do that without git log. Turns out, there is. This git command combined with a grep for the file name or partial file name (like a .swp extension) will return you a nice list of files matching your description.
git ls-tree --full-tree -r HEAD | grep <filename or string to search for>
For example, to list all .swp files, you'd run
git ls-tree --full-tree -r HEAD | grep .swp
Written by Shane Riley
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Version control
Authors
jasdeepkhalsa
10.18K
haeck
8.627K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#