I always try to commit covering all my code with tests. But sometimes, I make too many changes and I commit even if not all code is covered. These times I need to check files changed last or a particular commit to see if are covered or not. Is will be useful to know a way to list (via console) all files changed in last commit. Last commit, or a particular commit. Now I do it with SourceTree but I dont love to pass from console to sourcetree and again to sourcetree to console.
Can someone help me?
If you want just the filenames that were changed, try...
git show --pretty="format:" --name-only
It will show you all the files that changed in the last commit of the current branch you're on.
If you don't want to enter less
, use...
git diff-tree --no-commit-id --name-only -r HEAD
git diff --name-only
or git diff --name-status
are two standard ways to do this: you can give them any single commit, to compare the current work-tree to that commit, or any pair of commits to compare those two.
You can also add diff options to git show
, so git show --name-only
prints the log message and then the list of files; git show --name-status
adds the status letters as well. This works slightly differently for merge commits, as git show
defaults to using a "combined diff" (see the git diff documentation , about halfway down, about combined diffs; note that with -m
, git show
will produce multiple separate diffs instead). (And as alex noted you can alter or suppress the header information with --pretty=format:<directives>
.)
I like one of the very old commands, git whatchanged
, myself (it's a variant of git log
; git log --raw
does the same thing). I have seen hints that git whatchanged
might go away, but at least git log --raw
should stick around. The same output format is used in git diff --raw
; again, see the git diff documentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.