20

When I check out a previous commit of a git repository, 'git log' no longer shows commits that were committed after the currently checked out commit.

So, the question is: how do get a log of commits after the currently checked out one?

PlankTon
  • 12,443
  • 16
  • 84
  • 153

2 Answers2

29

You can use the --all flag to see all revisions, as in

git log --all

If you are just interested in the future revisions, you can also use

git log ..@{1}      # assuming you just switched from the future master
git log ..abcdef    # assuming abcdef is the newest future commit
phihag
  • 278,196
  • 72
  • 453
  • 469
  • can you explain the `..@{1}`? – drzaus Nov 28 '14 at 19:48
  • @drzaus `@{n}` is the n-th commit in your current branch, so `@{1}` is simply the newest commit in the current branch. The double-dot `..` indicates show everything reachable from the commit to the right that is not reachable from the commit to the left. Therefore, `HEAD..@{1}` shows everything that is reachable from the newest commit in the current branch but not the current commit (and `HEAD` can be left out). – phihag Nov 28 '14 at 21:39
3

The problem is: you don't know the children commits, only the parent comments.
And if you checkout directly a commit SHA1, you are in Detached HEAD mode (ie not on any branch).

One potential solution would be to list all the branches which contains your commit: "How to know which branch a “git log” commit belongs to?".
And then do a git log for each of those branches.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250