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. Missing artifact com.sun:tools:jar:1.5.0的解决方案

    今天在用maven的时候遇到一个问题pom.xml提示Missing artifact com.sun:tools:jar:1.5.0 试过改eclipse的eclipse.ini文件,也试过在ecl ...

  2. 函数fsp_seg_inode_page_get_nth_inode

    #define FSEG_ARR_OFFSET (FSEG_PAGE_DATA + FLST_NODE_SIZE) #define FSEG_PAGE_DATA FIL_PAGE_DATA #defi ...

  3. IE中Ajax数据缓存的问题

    在IE中,Ajax回来的数据会有缓存的现象发生,解决方式: 1,改变URL,每次请求加一个随机数参数Math.random()或者new Date().getTime(),这样IE会认为URL不一样, ...

  4. 使用VSS2005的时候报错:输入正确的服务器地址依然出错了

    使用VSS2005的时候报错:输入正确的服务器地址依然出错了 使用VSS2005的时候报错: 在安装完vss客户端,进入vss服务器的时候,需要vss服务器的ip和数据库名称.以及初始化文件, 我在进 ...

  5. HDU 5698 瞬间移动

    瞬间移动 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submis ...

  6. MyEclipse2014安装ADT插件(适用于其他版本)

    这次,本文采用公认的最佳插件安装方式——link方式来安装ADT插件,此方法适用于Eclipse以及MyEclipse其他版本.下面为大家一一道来: 大致过程如下: 官方的在线安装很麻烦,找了很久,终 ...

  7. HDU 1024 Max Sum Plus Plus 简单DP

    这题的意思就是取m个连续的区间,使它们的和最大,下面就是建立状态转移方程 dp[i][j]表示已经有 i 个区间,最后一个区间的末尾是a[j] 那么dp[i][j]=max(dp[i][j-1]+a[ ...

  8. 设计模式_Visitor_访问者模式

    形象例子: 情人节到了,要给每个MM送一束鲜花和一张卡片,可是每个MM送的花都要针 对她个人的特点,每张卡片也要根据个人的特点来挑,我一个人哪搞得清楚,还是找花店老板和礼品店老板做一下Visitor, ...

  9. oracle修改process和session数

    第一步:连接服务器,输入sqlplus 第二步:以sysdba身份登陆 第三步:查看和修改processes和sessions参数 1. 查看processes和sessions参数 select * ...

  10. 题目1023:EXCEL排序(多关键字+快排+尚未解决)

    http://ac.jobdu.com/problem.php?pid=1023 题目描述: Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. 对每个测试用例,首先输出1行“Ca ...