git rebase 后找回消失的commit

在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

NAMEgit-reflog - Manage reflog informationSYNOPSISgit reflog <subcommand> <options>DESCRIPTIONThe 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 localrepository. 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 toone 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 thereference provided in the command-line (or HEAD, by default). The reflog covers all recent actions, and inaddition 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 thanexpire-unreachable time and not reachable from the current tip, are removed from the reflog. This is typicallynot 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. "gitreflog delete master@{2}"). This subcommand is also typically not used directly by end users.OPTIONSOptions for showgit reflog show accepts any of the options accepted by git log.Options for expire--allProcess the reflogs of all references.--expire=<time>Prune entries older than the specified time. If this option is not specified, the expiration time is takenfrom the configuration setting gc.reflogExpire, which in turn defaults to 90 days.  --expire=all prunesentries 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 isnot specified, the expiration time is taken from the configuration setting gc.reflogExpireUnreachable, whichin 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).--updaterefUpdate the reference to the value of the top reflog entry (i.e. <ref>@{0}) if the previous top entry waspruned. (This option is ignored for symbolic references.)…………

git rebase 后找回消失的commit相关推荐

  1. git rebase branch内部调整 调整commit顺序

    git rebase -i commitID commitID相当于根,所以调整的是下游的commitID 命令行处理 1.准备数据 文本内容 version1 version2 version3 v ...

  2. Git Rebase后,本地代码丢失解决方法

    问题描述: 提交代码时,因为文件太大,多次push失败,然后打算回退,rebase了两次,本地代码丢失了,吓得我差点跳起来. lcc@lcc MyDoc$ git reset --hard 9c15d ...

  3. git rebase后撤回

    1.git reflog  查看所有操作日志 2. git reset --hard  bbc9da41b5(commitid)  回到初始状态

  4. 找回git rebase --skip消失的代码

    多人开发项目的时候,大家都会用到git rebase这一命令,那么,merge报错时一般有两种选择: 一.解决冲突 处理好冲突文件,然后重新提交,并继续rebase git add . git reb ...

  5. git 代码没了,git rebase 合并提交记录,git stash

    xx 问题 git合并提交记录 创建提交记录 合并提交记录 rebase有冲突 合并后的本地路径提交到远程 其中的参数 pick 改变提交 5.txt 和 4.txt 的顺序 删除某一个提交 rewo ...

  6. Git rebase命令实战

    一.前言 一句话,git rebase 可以帮助项目中的提交历史干净整洁!!! 二.避免合并出现分叉现象 git merge操作 1.新建一个 develop 分支   2.在develop分支上新建 ...

  7. git rebase的两种用法(最全)

    rebase的两种用法 用法一: 合并当前分支的多个commit记录 1. 找到想要合并的commit, 使用rebase -i 2. 进入Interact交互界面 3.使用s命令 合并到上一个com ...

  8. git rebase 修改备注信息

    git commit 未push 修改备注未push比较简单① $ git commit --amend 进行修改② 按esc退出编辑模式,输入:wq保存并退出 注意中文esc请切换至英文③ $ gi ...

  9. 合并代码还在用git merge吗?我们都用git rebase!

    欢迎关注方志朋的博客,回复"666"获面试宝典 git merge 和 git rebase的区别 目的都是将一个分支的 commit 合并到到另外一个分支中去. git merg ...

最新文章

  1. Asp.NET中常用的一些优化性能的方法
  2. docker rails mysql_Rails Docker开发环境配置
  3. Leetcode 188.买卖股票的最佳时机IV
  4. 剑指offer-99.调整数组顺序使奇数位于偶数前面
  5. 北邮OJ 1005. 16校赛-Hawei Learning C
  6. JVM从入门到精通(七):GC常用参数,Method Area,JVM调优案例分析
  7. 一文读懂如何用LSA、PSLA、LDA和lda2vec进行主题建模
  8. Codeforces Round #618 (Div. 2)-C. Anu Has a Function
  9. 非递归遍历二叉树(算法导论第三版第十章10.4-5)
  10. 加工中心刻字宏程序_FANUC OI系列图书——车床、铣床及加工中心编程
  11. [树状数组][哈希]JZOJ 3240 Seat
  12. 摄像头图像分析目标物体大小位置_对智能驾驶系统三种环境传感器布局的冗余关系分析...
  13. 基本操作1-本地仓库连接远程仓库
  14. Postgres外部表示例
  15. 《C++ Primer Plus》读书笔记之七—内存模型和名称空间
  16. flex 1037:包不能嵌套
  17. 代码健壮性 —— 边界条件的判断
  18. asp.net core的TagHelper简单使用
  19. MVVM模式下,自定义用户控件不执行COMMAND的原因
  20. Excel 中 YEAR 函数公式语法和用法示例介绍

热门文章

  1. JS(JavaScript)的初了解3(更新中···)
  2. (一)Spring MVC简介
  3. IT技术分类和就业特点
  4. 详细到没朋友,一文帮你理清Linux 用户与用户组关系~
  5. bootstrap的分页
  6. VueJS 开发常见问题集锦
  7. 联想服务器开机自动重启,解决联想电脑开机一半自动重启的方法
  8. 阅读书源最新2020在线导入_书源篇三及6.5.0版本介绍
  9. db2v9/9.5高级应用开发_macOS 10.15 全新音乐 app 将基于 iTunes 开发,原生 Mac 应用
  10. java经常会出现异常的是,“Java异常Exception”总结