用法

git reflog

显示整个本地仓储的commit, 包括所有branch的commit, 甚至包括已经撤销的commit, 只要HEAD发生了变化, 就会在reflog里面看得到. git log只包括当前分支的commit.

git reflog --relative-date

显示相对时间的commit纪录.

讨论

每一次当前HEAD发生改变(包括切换branch, pull, 添加新commit)一个新的纪录就会被添加到reflog.

例子

运行git reflog

0a2e358 HEAD@{0}: reset: moving to HEAD~2
0254ea7 HEAD@{1}: checkout: moving from 2.2 to master
c10f740 HEAD@{2}: checkout: moving from master to 2.2

上面的reflog展示了从master到2.2分支, 然后在会到master, 然后在reset到老的commit.

如果你发现上面的reset是一次意外是一个错误. 可以使用下面的命令反悔:

git reset --hard 0254ea7

  

[译]git reflog的更多相关文章

  1. git reflog 和git log :no branch git 提交方式

    git reflog 和git log的区别,外加git cherry-pick的一种用法 git reflog 可以查看所有分支的所有操作记录(包括(包括commit和reset的操作),包括已经被 ...

  2. Git相关二三事(git reflog 和彩色branch)【转】

    转自:https://www.jianshu.com/p/3622ed542c3b 背景 git太常用了,虽然,用起来不难,但也有很多小技巧的东西... 1. 后悔药 哪天不小心,写完代码,没comm ...

  3. Git log和git reflog

    1.git log  log命令可以显示所有提交过的版本信息.显示信息如下: $ git log commit e1bdff6e4830e09383078c860f45334d03771b03 (HE ...

  4. git log 与 git reflog 的 区别

    git log: commit 的版本日志 包含提交的版本 操作者 日期 (方便查看commit的版本,但是版本回退后,使用git log 看不到回退版本号之后的版本记录) commit ce0d69 ...

  5. 利用git reflog找回错误的重置

    在开发中经常需要reset分支,如果在reset前没有记住分支指向的提交ID,想要重置回原来的提交恐怕大多数开发者是重新拉取远程版本库,再rebase分支.但如果连不上远程版本库或没有远程版本怎么办呢 ...

  6. git reflog查看所有操作记录

    git reflog 可以查看所有分支的所有操作记录(包括(包括commit和reset的操作),包括已经被删除的commit记录,git log则不能察看已经删除了的commit记录 具体一个例子, ...

  7. 比 git log 更强大的 git reflog

    最近做了个骚操作 git checkout commitId 修改了部分内容 git add . git commit -m '修改了些东西'   -> 此时git 会自动生成一个新的 comm ...

  8. git切换分支导致代码丢失找回(git reflog找回错误的重置)

    1.使用git reflog查看日志 2.切换到丢失的分支 3. 创建一个临时分支  如(diff),并切换到dev(原分支),然后合并diff到dev分支 4.查看状态 5.强制合并,然后提交到de ...

  9. Git reflog 引用日志使用详解

    本章节主要介绍 git reflog 命令. Git 使用一种称为引用日志或"reflogs"的机制来跟踪分支顶端的更新. 许多 Git 命令接受用于指定引用或"ref& ...

随机推荐

  1. 使用Chrome或Fiddler抓取WebSocket包

    首先,HTTP是建立在TCP协议基础上的,而WebSocket通常也是建立在TCP上,所以说为什么有些网页游戏抓不到包而有些又可以,这仅是因为你使用的抓包工具是针对了HTTP的通信协议. 我先从抽象的 ...

  2. 利用PHPMailer发送邮件时报错

    利用thinkphp集成PHPMailer发送邮件时报错:Failed to connect to server: Unable to find the socket transport “ssl” ...

  3. Security configuration of SSH login entry - enterprise security practice

    catalog . 引言 . 修改ssh端口 . 禁用root远程ssh登录 . 只使用SSH v2 . 限制用户的SSH访问 . 禁用.rhosts文件 . 禁用基于主机的身份验证 . 基于公私钥的 ...

  4. HFSS使用记录

    一.基本设置 1.Tools \ Options,各种基本设置 1.1 Tools \ Options \ HFSS Options-> Duplicate boundaries/mesh op ...

  5. php Unable to find the wrapper "https"

    php -m | grep -i --color openssl php 没有openssl模块 cd /data/source/php-5.3.29/ext/openssl #php的解压包下面 y ...

  6. CF 444C DZY Loves Physics(图论结论题)

    题目链接: 传送门 DZY Loves Chemistry time limit per test1 second     memory limit per test256 megabytes Des ...

  7. 第二次作业——C++学习

    课程选择: 以往在自学的过程就比较留意一些自学的网站,所以这次"C++自学"感觉找课程还是比较轻松的. 因为之前网页等学习都是在慕课网(视频学习个人感觉有时挺费时间的,特别是有时以 ...

  8. 逐行读取txt文件

    header("Content-type:text/html; charset=utf-8"); $handle = fopen('test.php', 'r') or die(' ...

  9. Docker入门教程(二)命令

    Docker入门教程(二)命令 [编者的话]DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第二篇,介绍了Docker的基本命令以及命令的用法和功能. 在Docker ...

  10. c#.net WinForm 线程内 调用窗体控件

    richTextBox1.BeginInvoke(new EventHandler(delegate { richTextBox1.AppendText("正在提交服务器..\r\n&quo ...