git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How do I...

From
Linus Torvalds <torvalds@osdl.org>
Date
May 6, 2005, 18:58 UTC
Message-ID
<Pine.LNX.4.58.0505061145450.2233@ppc970.osdl.org>
In-Reply-To
<427B3DB3.4000507@tuxrocks.com>
On Fri, 6 May 2005, Frank Sorenson wrote:
Show 10 quoted lines
> 
> Okay, I've got some "How can I?" questions.  I hope I'm not the only one
> still working to "git it".
> 
> How can I git a list of commits that have modified a particular file?
> For example, I'd like to do something like this:
> # git-file-revs Makefile
> f7eb55878f11575281add2a5726e483aed5e45bb
> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Ok, I now have the perfect interface for _most_ uses of this thing.

For example, let's say that you are interested in "what changed in the USB input layer lately". You can now do

	git-rev-list | git-diff-tree -p -v --stdin drivers/usb/input | less -S

and you'll get some very readable output that tells you _exactly_ what has changed to any file in that subdirectory.

Or, let's say that you're the author of the gt96100 ethernet driver (just to pick one that has both a .c and a .h file and that has had changes in the current git tree, you'd do:

	git-rev-list HEAD | git-diff-tree -p -v --stdin drivers/net/gt96100eth.* | less -S

and it gives you _exactly_ what you want (ie thanks to how diff-tree works, you can give it any number of files or directories you're interested in).

Normally, this thing will ignore merge commits, but if you want to see the merges that the changes came through (a merge _can_ have real changes of its own too), add the "-m" flag to the git-diff-tree thing.

Try out the above examples on the current kernel tree (and with my most current git version as of five minutes ago - it shows up at least on gitweb, but I don't know if it's mirrored out with rsync yet). Very pretty. Very useful.

		Linus
Previous: Benjamin Herrenschmidt
Message 24 of 24 in “How do I...”
  1. Frank SorensonMay 6, 2005
  2. Thomas GlanzmannMay 6, 2005
  3. Thomas GlanzmannMay 6, 2005
  4. Dave KleikampMay 6, 2005
  5. Frank SorensonMay 6, 2005
  6. Dave KleikampMay 6, 2005
  7. Frank SorensonMay 6, 2005
  8. Linus TorvaldsMay 6, 2005
  9. Junio C HamanoMay 6, 2005
  10. Frank SorensonMay 6, 2005
  11. Daniel BarkalowMay 6, 2005
  12. Frank SorensonMay 6, 2005
  13. Linus TorvaldsMay 6, 2005
  14. David WoodhouseMay 6, 2005
  15. Linus TorvaldsMay 6, 2005
  16. David WoodhouseMay 6, 2005
  17. Linus TorvaldsMay 6, 2005
  18. David WoodhouseMay 6, 2005
  19. Linus TorvaldsMay 6, 2005
  20. David WoodhouseMay 7, 2005
  21. Thomas KolejkaMay 6, 2005
  22. David WoodhouseMay 6, 2005
  23. Benjamin HerrenschmidtMay 7, 2005
  24. Linus TorvaldsMay 6, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.