git reflog expire [--dry-run] [--stale-fix] [--verbose]
[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
- git reflog [show] [log-options]
+git reflog delete ref@\{specifier\}...
+
+ git reflog [show] [log-options] [<ref>]
Reflog is a mechanism to record when the tip of branches are
updated. This command is to manage the information recorded in it.
The subcommand "show" (which is also the default, in the absence of any
subcommands) will take all the normal log options, and show the log of
- `HEAD`, which will cover all recent actions, including branch switches.
- It is basically an alias for 'git log -g --abbrev-commit
- --pretty=oneline', see gitlink:git-log[1].
+ the reference provided in the command-line (or `HEAD`, by default).
+ The reflog will cover all recent actions (HEAD reflog records branch switching
+ as well). It is an alias for 'git log -g --abbrev-commit --pretty=oneline';
+ see linkgit:git-log[1].
+
+ The reflog is useful in various git commands, to specify the old value
+ of a reference. For example, `HEAD@\{2\}` means "where HEAD used to be
+ two moves ago", `master@\{one.week.ago\}` means "where master used to
+ point to one week ago", and so on. See linkgit:git-rev-parse[1] for
+ more details.
+To delete single entries from the reflog, use the subcommand "delete"
+and specify the _exact_ entry (e.g. ``git reflog delete master@\{2\}'').
+
OPTIONS
-------
'
+test_expect_success 'delete' '
+ echo 1 > C &&
+ test_tick &&
+ git commit -m rat C &&
+
+ echo 2 > C &&
+ test_tick &&
+ git commit -m ox C &&
+
+ echo 3 > C &&
+ test_tick &&
+ git commit -m tiger C &&
+
+ test 5 = $(git reflog | wc -l) &&
+
+ git reflog delete master@{1} &&
+ git reflog show master > output &&
+ test 4 = $(wc -l < output) &&
+ ! grep ox < output &&
+
+ git reflog delete master@{07.04.2005.15:15:00.-0700} &&
+ git reflog show master > output &&
+ test 3 = $(wc -l < output) &&
+ ! grep dragon < output
++
++'
++
+ test_expect_success 'prune --expire' '
+
+ before=$(git count-objects | sed "s/ .*//") &&
+ BLOB=$(echo aleph | git hash-object -w --stdin) &&
+ BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ git reset --hard &&
+ git prune --expire=1.hour.ago &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ test-chmtime -86500 $BLOB_FILE &&
+ git prune --expire 1.day &&
+ test $before = $(git count-objects | sed "s/ .*//") &&
+ ! test -f $BLOB_FILE
+
'
test_done