Sometimes you find a bug in your project that has been around for a while without being noticed; it can be hard to track down where that bug was introduced and why just by searching through logs and diffs. Git has a slick tool called git bisect that can be used to find out which commit introduced problem in our code - it creates a binary search where the programmer can mark each search commit as good or bad; by the end of the bisect, Git shows you exactly which commit introduced the issue. In this lesson, we walk through an example of using git bisect from start to finish.

To get started:

git bisect start

First, we need to find out which commit cause the problem, now assume it is the lastest commit, so we need to mark it as 'bad':

git bisect bad

Then , we need to find out which commit works fine, then mark it as good:

git log --oneline // to pick one which you are sure code works fine

# Then get the commit id

git bisect good <commit_id>

Then git will show you the commits which stay between the bad and good commits and will automatically checkout the next commit. Then you can do the testing and find out whether this commit is bad or not, if it is bad then mark as 'bad' or the other way around.

Finnally git bisect will find out the bad commit which introduce the bugs, but we are still in the bisecting state, to back to normal, we need to run:

git bisect reset

[Practical Git] Diagnose which commit broke something with git bisect的更多相关文章

  1. [原]git的使用(一)---建立本地仓库、add和commit、status和git diff、版本回退使用git reset

    在window下已经安装了git的环境 1.建立本地仓库 mkdir   test     #建立test目录 cd   test        #进入目录 git  init           # ...

  2. Git error on commit after merge - fatal: cannot do a partial commit during a merge

    Git error on commit after merge - fatal: cannot do a partial commit during a merge this answer is : ...

  3. 第二章-如何使用github建立一个HelloWorld项目,git的add/commit/push/pull/fetch/clone等基本命令用法。--答题人:杨宇杰

    1.配置Git 首先在本地创建ssh 秘钥:在git bash输入: $ ssh-keygen -t rsa -C "your_email@youremail.com" eg:$ ...

  4. 第二章——建立一个HelloWorld项目,练习使用git的add/commit/push/pull/fetch/clone等基本命令。比较项目的新旧版本的差别-----答题者:徐潇瑞

    1.首先下载安装git,很简单所以就不详细说了,当弹出一个类似的命令窗口的东西,就说明Git安装成功 2.因为Git是分布式版本控制系统,所以需要填写用户名和邮箱作为一个标识 3.接着,注册githu ...

  5. 通过git rebase修改commit message

    今天发现一个项目的git commit message中的单词拼错了,需要修改一下.但这样简单的修改,需要通过git rebase才能完成. 首先要git rebase到需要修改message的那个c ...

  6. Git 版本退回commit

    有的时候错误提交了commit,需要版本退回. 先用git log查看一下节点版本号commit_id $ git log 再用git reset退回 $ git reset -soft commit ...

  7. commit lint规范化团队git提交信息

    一.快速提交符号angular编码规范的提交信息 1.命令行中安装commitizen: npm install -g commitizen commitizen init cz-convention ...

  8. Need help with git commit - Error : "error: cannot run gpg: No such file or directory error: could not run gpg. fatal: failed to write commit object"support (self.git)

    参考:https://www.reddit.com/r/git/comments/4jflp1/need_help_with_git_commit_error_error_cannot_run/ It ...

  9. Git 合并多次 commit 、 删除某次 commit

    Git 合并多次 commit 有时候在一个分支的多次意义相近的 commit,会把整个提交历史搞得很混乱,此时可以将一部分的 commit 合并为一个 commit,以美化整个 commit 历史, ...

随机推荐

  1. poj3月题解

    poj2110 二分答案+bfs判定 poj2112 二分答案+最大流判定(二分答案真乃USACO亲儿子) poj1986 裸的LCA,值得注意的是,树中任意两点的距离可以等于这两点到根的距离减去2* ...

  2. poj2月下旬题解

    poj2388 水题 poj1273 最大流初步 poj2456 简单的二分答案 poj2309 论lowbit的重要性 poj1734 floyd求最小环 poj1001 细节题 poj2184 0 ...

  3. jquery提示气泡

    <link href="css/manhua_hoverTips.css" type="text/css" rel="stylesheet&qu ...

  4. tomcat+dbcp+jndi 配置

    1)添加jar包 tomcat6中 TOMCAT_HOME/lib 下是公用jar包 dbcp需要3个jar包:Jakarta-Commons DBCP,Jakarta-Commons Collect ...

  5. CF GYM 100703L Many questions

    题意:题意真坑……龙要问一系列问题,王子骑士公主分别以一个整数回答,如果王子和公主答案差的绝对值比骑士和公主答案差的绝对值小则说王子和公主的答案更相似,反过来如果前者比后者大则说骑士和公主的答案更相似 ...

  6. tdx api z

    调用TdxAPI.dll函数 .DLL命令 TdxInit, 逻辑型, "TdxApi.dll", "TdxInit", , 初始化通达信实例,成功时返回tru ...

  7. 31、activity 四种工作模式

    一个应用通常(不一定)对应一个任务栈,相当于有个集合,保存了这个app里所有的页面栈的规则是先进后出,"进"就相当于打开了一个页面,"出"就相当于返回时关闭一个 ...

  8. 派遣例程与IRP结构

    提到派遣例程,必须理解IRP(I/O Request Package),即"输入/输出请求包"这个重要数据结构的概念.Ring3通过DeviceIoControl等函数向驱动发出I ...

  9. PHP与MySQL动态网站开发2

    处理HTML表单 <input type="text" name="city"/> 通过$_REQUEST['city'];访问,$_REQUEST ...

  10. STM32硬件调试详解

    STM32的基本系统主要涉及下面几个部分: 一.电源 1).无论是否使用模拟部分和AD部分,MCU外围出去VCC和GND,VDDA.VSSA.Vref(如果封装有该引脚)都必需要连接,不可悬空: 2) ...