# git rebase 后找回消失的commit

reflog : reference logs

$git reflog d185b35 HEAD@{0}: rebase finished: returning to refs/heads/passport d185b35 HEAD@{1}: rebase: checkout origin/passport 4ab8e52 HEAD@{2}: checkout: moving from passport_email to passport d185b35 HEAD@{3}: checkout: moving from passport to passport_email 4ab8e52 HEAD@{4}: checkout: moving from passprot_bak to passport d185b35 HEAD@{5}: checkout: moving from passport to passprot_bak 4ab8e52 HEAD@{6}: checkout: moving from passprot_bak to passport d185b35 HEAD@{7}: commit: 添加邮件发送处理操作 ............  这里显示了commit 的sha, version, message，找到你消失的commit，然后可以使用这个‘消失的’commit重新建立一个branch. $git checkout -b branch-bak [commit-sha]

NAME

SYNOPSIS
git reflog <subcommand> <options>

DESCRIPTION
The command takes various subcommands, and different options depending on the subcommand:

git reflog [show] [log-options] [<ref>]
git reflog expire [--expire=<time>] [--expire-unreachable=<time>]
[--rewrite] [--updateref] [--stale-fix]
[--dry-run] [--verbose] [--all | <refs>...]
git reflog delete [--rewrite] [--updateref]
[--dry-run] [--verbose] ref@{specifier}...

Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local
repository. Reflogs are 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 in this local repository", and so on. See gitrevisions(7) for more details.

This command manages the information recorded in the reflogs.

The "show" subcommand (which is also the default, in the absence of any subcommands) shows the log of the
reference provided in the command-line (or HEAD, by default). The reflog covers all recent actions, and in
addition the HEAD reflog records branch switching. git reflog show is an alias for git log -g --abbrev-commit

The "expire" subcommand prunes older reflog entries. Entries older than expire time, or entries older than
expire-unreachable time and not reachable from the current tip, are removed from the reflog. This is typically
not used directly by end users -- instead, see git-gc(1).

The "delete" subcommand deletes single entries from the reflog. Its argument must be an exact entry (e.g. "git
reflog delete master@{2}"). This subcommand is also typically not used directly by end users.

OPTIONS
Options for show
git reflog show accepts any of the options accepted by git log.

Options for expire
--all
Process the reflogs of all references.

--expire=<time>
Prune entries older than the specified time. If this option is not specified, the expiration time is taken
from the configuration setting gc.reflogExpire, which in turn defaults to 90 days.  --expire=all prunes
entries regardless of their age; --expire=never turns off pruning of reachable entries (but see
--expire-unreachable).

--expire-unreachable=<time>
Prune entries older than <time> that are not reachable from the current tip of the branch. If this option is
not specified, the expiration time is taken from the configuration setting gc.reflogExpireUnreachable, which
in turn defaults to 30 days.  --expire-unreachable=all prunes unreachable entries regardless of their age;
--expire-unreachable=never turns off early pruning of unreachable entries (but see --expire).

--updateref
Update the reference to the value of the top reflog entry (i.e. <ref>@{0}) if the previous top entry was
pruned. (This option is ignored for symbolic references.)
…………