24

how to do a git status to view changed files in a past commit?

NOTE: this question might have already been asked, but phrased much differently. however, I am astounded to see that searching for the following expression on Google yields no useful results: git status for past commit.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Guillaume Chevalier
  • 9,613
  • 8
  • 51
  • 79
  • 1
    What information do you want to retrieve from said `git status for past commit`? – byxor Jun 13 '17 at 17:53
  • 3
    `git status` isn’t used on a commit, so that might be why you’re getting no results. Are you looking for `git show [--stat] `? – Ry- Jun 13 '17 at 17:53
  • `git status` tells you about the state of your *working tree*. What would that mean for a commit? – Oliver Charlesworth Jun 13 '17 at 17:53
  • To expand slightly on @OliverCharlesworth comment, `git status` prints: (1) information about the current branch (and vs its upstream if set); (2) the state of any in-progress rebase, merge, etc., in the work-tree; and (3) the result of comparing `HEAD` to the index and the index to the work-tree, if you are not in the middle of a merge. Only part of (3) involves an existing commit and then *if and only if* you are not still merging. – torek Jun 13 '17 at 18:00
  • `git status` for past commits is spelled either `git log` or `git show`. – twalberg Jun 13 '17 at 18:51
  • What I want is to show is roughly what would have a `git status` shown in the past before adding and committing files, for that given commit. To sum up, I wanted to see which files changed with a commit (and I am uninterested in files which have simply not been added nor removed). – Guillaume Chevalier Jun 13 '17 at 18:58

3 Answers3

28

git show --name-status <commit>

eftshift0
  • 26,375
  • 3
  • 36
  • 60
14

I found:

git show --stat --oneline b8351c4

Where b8351c4 is the regarded commit.

Guillaume Chevalier
  • 9,613
  • 8
  • 51
  • 79
6

git status is the wrong command here. If you want to see what a previous commit did you should use git show <commit>.

Mureinik
  • 297,002
  • 52
  • 306
  • 350