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. 变量赋值(引用) php内核的实现(二)

    <?php $a=1; $b=&$a; $c=2; $a=&$c; echo $a."\n"; echo $b; 2 1 结论: 首先保存 左值的内存地址, ...

  2. 【转载】LVS+MYCAT+读写分离+MYSQL主备同步部署手册(邢锋)

    LVS+MYCAT+读写分离+MYSQL主备同步部署手册 1          配置MYSQL主备同步…. 2 1.1       测试环境… 2 1.2       配置主数据库… 2 1.2.1  ...

  3. 根据Excel列类型获取列的值

    using System.Data; using System.IO; using System.Text; using System.Web; using NPOI.SS.UserModel; us ...

  4. hbase分页查询

    为了广大技术爱好者学习netty,在这里帮新浪微博@nettying宣传下他出版的新书 <netty权威指南>@nettying兄在华为NIO实践多年,这本书是他的技术和经验的一个结晶.N ...

  5. redhat mysql 远程开启

    2)开启远程接入.登录到数据库,对mysql.user进行操作 表Mysql.user记录了不同用户不同主机不同的权限.可通过命令查看: Select * from mysql.user : 插入新用 ...

  6. 自己手动写http服务器(2)

    tringBuilder response =new StringBuilder(); //1) HTTP协议版本.状态代码.描述 response.append("HTTP/1.1&quo ...

  7. Nginx负载均衡SFTP

    1.CentOS安装SFTP,参考 2.Nginx-1.8.1 下载 ,Nginx_TCP插件 下载 3.安装Nginx [root@localhost nginx-1.8.1]# yum -y in ...

  8. adb logcat调试中常用的命令介绍

    Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过 logcat 命 令来查看和使用. adb logcat 命令格式 : ad ...

  9. HW6.14

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  10. Java HashMap 源码解析

    今天正式开始分析具体集合类的代码,首先以既熟悉又陌生的HashMap开始. 签名(signature) public class HashMap<K,V> extends Abstract ...