在git rebase操作时,存在冲突时,使用git rebase --abort
处理后,结果发现commit的修改和记录都没有了。(使用git rebase --skip
处理,也有导致commit消失不见得情况),就是使用git log
看不到。
并不是真的在git中完全消失了。
这是可以使用reflog命令列出log 信息。 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]
然后可以出来冲突,再git add
, git commit
, git push
等操作,把修改提交。
最后,看看git help
name
git-reflog - manage reflog information
synopsis
git reflog
description
the command takes various subcommands, and different options depending on the subcommand:
git reflog [show] [log-options] [[]
git reflog expire [--expire=]
] [--expire-unreachable=
]
[--rewrite] [--updateref] [--stale-fix]
[--dry-run] [--verbose] [--all | ...]
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
--pretty=oneline; see git-log(1) for more information.
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=
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=
prune entries older than
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. [@{
0}) if the previous top entry was
pruned. (this option is ignored for symbolic references.)
…………]