nonopolarity
nonopolarity

Reputation: 151106

Git's <refname>@{<date>} format doesn't always work?

Looking at the gitrevisions docs, it seems like I can do something like:

git show "master@{3 minutes ago}":foo
git show "master@{1 minute ago}":foo
git log "master@{20 minutes ago}"
git log "master@{1 minute ago}"

where the foo above is just a simple text file.

So those seem to work, showing different content for foo or for the log. But if I

git clone https://github.com/git/git.git
cd git

and now if I do

git log "master@{100 days ago}"

then I get the same log as if I am doing git log -- how can this be made to work?

Upvotes: 0

Views: 53

Answers (1)

Jan Krüger
Jan Krüger

Reputation: 18530

The @{foo} syntax accesses reflogs, not the branch history. A reflog stores changes you made to a branch locally. It makes a note when you commit something, but also when you reset/rewrite the branch in some way. So, reflogs can be used to undo rather invasive changes made to a branch.

The flip side of that is that the syntax can only be used to refer to changes you made yourself, in exactly that copy of the repository – but you can access changes that aren't visible in the history, specifically changes that rewrite history.

If you want to filter normal log output by date, look at the options --since/after and --until/before.

Upvotes: 1

Related Questions