In the last lesson, we learned how to format the git log output; in this lesson we will learn how to filter down to a specific set of commits. By default, git log shows every commit in a repo. We will walk through using a bunch of options to filter our git log commits to a more meaningful set (-n--after--before--author--grep-S-G--no-merges{ref}..{ref}{files}). We will also show how all of the formatting and filtering options can be composed together to query exactly what you are looking for in your commit history.

Show lasat N commit:

git log - // show last three commit

Show commits from a center time:

git log --after="yesterday" // Show the commit between yesterday and today
git log --after="10 minutes ago"
git log --after="2 weeks ago"
git log --after="3/15/16" // Match 15, 2016

Combine with --before:

git log --after="3/15/16" --before="yesterday"

The same as:

git log --since="3/15/16" --until="yesterday"

Filter by author:

git log --author="Tavor"

Filter by the commit message:

git log --grep="copyright"

Filter by the code using string:

git log -S"Math.random" -p // get all the commit which has Math.random changes in the code, and use -p option to see the code

Filter by the code using Regex:

git log -p -GMath\|random // Using 'G' without quotes and follow with regex math or random

Ingore the case:

git log -i --author="Jane" // search both for "Jane" and "jane"

git log --author="Jane" // search only for "Jane"

Filter out merges commit:

git log --no-merges

See the commits between two branch:

git log master..cool-feature

Search by files:

git log LIENCE.md README.md // search for lience and readme files

Example:

git log - README.md -p -i --author="Tavor" // Want to see last 3 change on README.md file by author Tavor, ignor the case, and show the code
git log -S"Math" --after="2 months ago" --oneline --stat

[Practical Git] Filter commit history with git log arguments的更多相关文章

  1. [Practical Git] Format commit history with git log arguments

    When running the git log command, we can pass in options as arguments toformat the data shown for ea ...

  2. git 版本(commit) 回退 -- 使用git reset 指令

    刚刚提交了三个commit, git reflog显示如下: 最后一个commit在文件末尾加了一行:v3,以此类推: 下面,使用git reset --hard commitID来进行commit回 ...

  3. Git 学习(三)本地仓库操作——git add & commit

    Git 学习(三)本地仓库操作——git add & commit Git 和其他版本控制系统如SVN的一个不同之处就是有暂存区的概念.这在上文已有提及,本文具体说明什么是工作区及暂存区,以及 ...

  4. git常用命令,学git代码管理

    下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote:远程仓库 一. ...

  5. Git详解之十 Git常用命令

    下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote:远程仓库 一. ...

  6. 10年阿里自动化测试架构师帮您收集的:git常用命令大全以及git原理图【泣血推荐,建议收藏】

    一.Git分布式版本控制简介 ​ Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势.本来想着只把最有用.最常用的 Git 命令记下来, ...

  7. Git学习01 --git add, git commit , git log ,git status, git reset --hard, head

    Git官方提供的快速入门教程:https://try.github.io/levels/1/challenges/1 特点:Git极其强大的分支管理:分布式版本 集中式版本控制系统,版本库是集中存放在 ...

  8. Git删除commit提交的log记录

    基于 GitFlow 工作流,可能某个提交(commit)导致了 bug,或者有多个提交需要返工,此时你就会用到删除提交. 接下来的内容都基于下面这张 git log 提交记录图来写.   git l ...

  9. [Git] Use git add --patch for better commit history and mitigating bugs

    Let's split our changes into separate commits. We'll be able to check over our changes before stagin ...

随机推荐

  1. 三维软件转Unity的系统单位设置研究

    Unity的系统单位为米,其他3D软件的模型导入,而保持和Unity的比例一致是非常重要的,下面对各软件进行测试: ㈠. 3dsmax 转 Unity的比例为100:1:也就是说Unity单位是3ds ...

  2. 让ie6支持fixed最简单和实用的方法

    <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...

  3. 漫谈MySql中的事务

    最近一直在做订单类的项目,使用了事务.我们的数据库选用的是MySql,存储引擎选用innoDB,innoDB对事务有着良好的支持.这篇文章我们一起来扒一扒事务相关的知识. 为什么要有事务? 事务广泛的 ...

  4. 【转】1.5 起步 - 初次运行 Git 前的配置

    原文网址:http://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5-%E5%88%9D%E6%AC%A1%E8%BF%90%E8%A1%8C-Git-%E5%8 ...

  5. (六)学习MVC之标签a提交页面

    标签<a>如何做到与<input type="submit"/>一样有提交页面信息的效果? @using (Html.BeginForm("Log ...

  6. 模拟post请求方法

    2

  7. tcxtreelist 展示图片 图像

    procedure TfrmstPostImageCollate.LoadCollateImage(AOrderID: integer);var mySql: string; node: TcxTre ...

  8. QT中使用 slot 传递 opencv 中得Mat对象以及 使用多线程集成开源代码。

    关于 slot传递 Mat 对象 以前一直是使用 Qtimer 定时器,设定超时后读取 dialog 对象的 Mat成员实现在 UI 里显示图像,发现这样对以后集成其他面向过程的代码增加了复杂度. 所 ...

  9. jdk源码调试功能

    JDK源码重新编译——支持eclipse调试JDK源码--转载 最近在研究jdk源码,发现debug时无法查看源码里的变量值. 因为sun提供的jdk并不能查看运行中的局部变量,需要重新编译一下rt. ...

  10. OpenStack Swift client开发

    如果你搭建好了Swift环境 ,你应该可以通过Swift 命令 来尝试去测试上传下载等功能,这是因为在安装Swift的时候,通常会安装一个python-swiftclient客户端,这个一个pytho ...