[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 历史, ...
随机推荐
- poj 3278 Catch That Cow (bfs)
题目:http://poj.org/problem?id=3278 题意: 给定两个整数n和k 通过 n+1或n-1 或n*2 这3种操作,使得n==k 输出最少的操作次数 #include<s ...
- Session简介
摘要:虽然session机制在web应用程序中被采用已经很长时间了,但是仍然有很多人不清楚session机制的本质,以至不能正确的应用这一技术.本文将详细讨论session的工作机制并且对在Java ...
- (五)学习JavaScript之firstChild 属性
参考:http://www.w3school.com.cn/jsref/prop_node_firstchild.asp 定义和用法 firstChild 属性返回指定节点的首个子节点,以 Node ...
- 我的Modbus Slave/Client开发历程(Rtu/AscII/Tcp)
我的Modbus Slave/Client开发历程(Rtu/AscII/Tcp) 分类: [自动化]2007-07-19 10:04 34038人阅读 评论(38) 收藏 举报 vb嵌入式dostcp ...
- UVA 10585 Center of symmetry
题意:给出一个点集,问这个集合有没有中心点使点集对称,这个点可以是点集中的点也可以不是点集的点. 解法:一开始我枚举每两个点连线的中点……结果T了orz当时也不知道怎么想的…… 将点按横坐标排序,如果 ...
- CXF之三 Tomcat中发布Web Service
服务接口及实现类请参考CXF之一 创建Maven Web项目,在pom.xml中添加CXF和spring Web的引用,由于CXFServlet需要Spring Web的支持. <project ...
- 【树莓PI】下载机
sudo app-get install ntfs-3g 读写ntfs格式的磁盘 mount -t ntfs /dev/sda4 /mnt/usb -o nls=utf8,umask=0 fdisk ...
- 命令rm
mv -r 递归删除文件夹内所有东西mv -i 交互式删除mv -f 强制删除,没有警告提示
- svn文件清理Bat脚本
@echo On@Rem C:\Users\caoxiancc\Desktop\Ueditor-thinkphp-master\Ueditor --svn跟路径@PROMPT [Com] @for / ...
- OpenCV2.3.1中tbb_debug.dll is missing的解决办法
方法1: 将\opencv\build\common\tbb\ia32目录下的tbb.dll复制改名为tbb_debug.dll 方法2: 若方法1失效,请将\openc ...