12

When I do the following in my working copy:

> git diff 'master@{1 hour ago}'

It prints

warning: Log for 'master' only goes back to Thu, 14 Jan 2016 15:37:11 -0500.

Yet when I do git log master, it clearly goes back farther:

commit bb9c80fb1c3895a9c11f7a60710497cc8406e71f
Author: Andy Edwards <andy@example.com>
Date:   Tue Jan 12 22:44:21 2016 -0600
...

Am I doing something wrong, or is this a git bug?

sanmai
  • 29,083
  • 12
  • 64
  • 76
Andy
  • 7,885
  • 5
  • 55
  • 61
  • 9
    The `master@` is using the reflog, which correlates to your local repository creation, and not the commit dates – Andrew C Jan 14 '16 at 21:57
  • What are you actually trying to do? – merlin2011 Jan 15 '16 at 00:31
  • @AndrewC does `HEAD@` mean something different from `master@`? I'm getting the same warning for both. – Andy Jan 15 '16 at 14:45
  • @merlin2011 I'm trying to make a script that periodically checks if files have changed and if so, regenerates some derived data and commits it back to the repo. I figured out another way to do it, but this still seems strange to me. – Andy Jan 15 '16 at 14:46
  • 1
    Okay, I'm going to modify this question to ask about how to refer to the commit log, not the reflog – Andy Jan 15 '16 at 14:50
  • Wait, I just grokked the problem with what I'm trying to do...in distributed version control, it's impossible for the commit history to be linear in time isn't it? :) – Andy Jan 15 '16 at 14:56
  • 3
    @AndrewC I think your comment would be a satisfactory answer, if you want more reputation – Andy Jan 15 '16 at 14:57
  • This may be helpful, if you are just looking for an easy way to figure out which commit to checkout: https://stackoverflow.com/a/50488492/28324 – Elias Zamaria Oct 31 '19 at 23:51

1 Answers1

1

Use git-whatchanged instead.

git whatchanged --since="1 hour ago" --patch
sanmai
  • 29,083
  • 12
  • 64
  • 76