[Practical Git] Diagnose which commit broke something with git bisect
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的更多相关文章
- [原]git的使用(一)---建立本地仓库、add和commit、status和git diff、版本回退使用git reset
在window下已经安装了git的环境 1.建立本地仓库 mkdir test #建立test目录 cd test #进入目录 git init # ...
- 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 : ...
- 第二章-如何使用github建立一个HelloWorld项目,git的add/commit/push/pull/fetch/clone等基本命令用法。--答题人:杨宇杰
1.配置Git 首先在本地创建ssh 秘钥:在git bash输入: $ ssh-keygen -t rsa -C "your_email@youremail.com" eg:$ ...
- 第二章——建立一个HelloWorld项目,练习使用git的add/commit/push/pull/fetch/clone等基本命令。比较项目的新旧版本的差别-----答题者:徐潇瑞
1.首先下载安装git,很简单所以就不详细说了,当弹出一个类似的命令窗口的东西,就说明Git安装成功 2.因为Git是分布式版本控制系统,所以需要填写用户名和邮箱作为一个标识 3.接着,注册githu ...
- 通过git rebase修改commit message
今天发现一个项目的git commit message中的单词拼错了,需要修改一下.但这样简单的修改,需要通过git rebase才能完成. 首先要git rebase到需要修改message的那个c ...
- Git 版本退回commit
有的时候错误提交了commit,需要版本退回. 先用git log查看一下节点版本号commit_id $ git log 再用git reset退回 $ git reset -soft commit ...
- commit lint规范化团队git提交信息
一.快速提交符号angular编码规范的提交信息 1.命令行中安装commitizen: npm install -g commitizen commitizen init cz-convention ...
- 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 ...
- Git 合并多次 commit 、 删除某次 commit
Git 合并多次 commit 有时候在一个分支的多次意义相近的 commit,会把整个提交历史搞得很混乱,此时可以将一部分的 commit 合并为一个 commit,以美化整个 commit 历史, ...
随机推荐
- bzoj3996
把这个式子弄清楚就知道这是最小割了 相当于,选某个点i有收入ai,i,会损失ci, 如果i,j都被选则有额外收入ai,j+aj,i 明显,对每个点i,连(s,i,∑ai,j) (i,t,ci) 对每对 ...
- 关于SqlParameter中IN子句查询的问题
今天调试到方法中代码: String hotelCodes =”’’,’’,’’”; string sqltext ="select * from HotelMedalInfo where ...
- Spring MVC 教程
目录 一.前言二.spring mvc 核心类与接口三.spring mvc 核心流程图 四.spring mvc DispatcherServlet说明 五.spring mvc 父子上下文的说明 ...
- TCP编程(七)
此为网络编程的一个系列,后续会把内容补上...
- Zen Coding support in WebStorm/PhpStorm
With the last WebStorm/PhpStorm EAP you can edit HTML and CSS code really fast usingZen Coding featu ...
- ExecuteStoreQuery
using (var webdb = new kyj_NewHouseDBEntities()) { string sql = "select * from developer where ...
- Tomcat配置JNDI数据源
经过3个多小时的努力,配置JNDI数据源(主要是通过DBCP连接池)终于搞定-还是Tomcat官方的说明好,不过全是英文的,大概还看得懂.百度上那么花花绿绿的太多了,一个也没成功!...本例使用的数据 ...
- Gen_server行为分析与实践
1.简介 Gen_server实现了通用服务器client_server原理,几个不同的客户端去分享服务端管理的资源(如图),gen_server提供标准的接口函数和包含追踪功能以及错误报告来实现通用 ...
- HDU 1736 美观化文字
美观化文字 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- 中文Win7下成功安装calabash-android步骤
Calabash-android是支持android的UI自动化测试框架,网上看见很多同学说,安装calabash比较费劲,特别是Windows下安装,也没有一个详细的安装手册可供参考.正好,今天在W ...