I need to check latest changes in a subdirectory of a git repo. I would like to get the latest commit info in one line (sha, author, message, and may be date). Is it possible?
Asked
Active
Viewed 2,486 times
1 Answers
7
git log -n 1 --format="%h %aN %s %ad" -- $directory

Fred Foo
- 355,277
- 75
- 744
- 836
-
1and add `-n 1` to only show the latest commit. For safety, in case you have any tags or branches that are named the same as the dir, place `--` before `$directory` – jbowes Oct 01 '12 at 10:24
-
@jbowes: yes, thanks. I'm lazy, so I usually just use `| head 1` to get only the first line :) – Fred Foo Oct 01 '12 at 10:27
-
Thanks! Maybe you can advice me how to list branches with latest commit date. This seems not possible with `git branch -av ...` EDIT: and remote branches as well! – Andrei Oct 01 '12 at 11:12
-
Ok, found a way `git for-each-ref --sort=-committerdate refs/ --format='%(refname) %(committerdate) %(authorname)'` – Andrei Oct 01 '12 at 11:21
-
It's just colors missing, but I better open another question for branch list. – Andrei Oct 01 '12 at 11:38