198

How can I view git log history for all files within a folder ?

I have found several posts on how to show log for a specific file, but haven't found for a specific folder.

Thomas Vervik
  • 4,325
  • 9
  • 36
  • 64

2 Answers2

257

You can use either foldername or foldername/*. Either way should work.

git log -- path/to/folder
git log -- path/to/folder/*

History of renamed files will not be followed with this method.

Please note that -- is optional as well. (from git log manual)

[--] <path>...

           Show only commits that are enough to explain how the files that match the specified paths came to be. See History Simplification below for
           details and other simplification modes.

           Paths may need to be prefixed with -- to separate them from options or the revision range, when confusion arises.
northtree
  • 8,569
  • 11
  • 61
  • 80
knittl
  • 246,190
  • 53
  • 318
  • 364
  • And deletions of directories under `path/to/folder` ? will they show up? – Zarathustra Jul 22 '16 at 12:19
  • @Zarathustra: yes. Using the first command (without `*`), they will definitely show up – knittl Jul 24 '16 at 15:00
  • 3
    Also of interest: Add a -p. You will get nice diffs in addition to the commit ids. – user18099 Mar 30 '17 at 09:49
  • 2
    I guess this was changed after 2016, as currently these two commands will only show commit logs: commit hash, author, date, and commit message - nothing else. – Juha Untinen Apr 08 '19 at 07:50
  • 1
    @JuhaUntinen what else should it show? `git log` only shows commit information. If you want to see file changes, provide the `-p` flag as mentioned in the previous comment – knittl Apr 08 '19 at 17:15
69

if you want to use a graphic tool, such as gitk, it works the same:

gitk -- path/to/folder
OSdave
  • 8,538
  • 7
  • 45
  • 60
  • I've been using sourcetree and like it. Wonder how does the gitk compare with sourcetree in UI aspects. – Feru Jun 12 '18 at 14:35
  • 1
    `gitk` has a very utilitarian UI, but is otherwise pretty good. If you're into pretty UI's, then you might also consider `Merge` (WIN/MAC/*NIX) from the Sublime Text team, and `Fork` (WIN/MAC). – ken May 31 '19 at 20:51