[Practical Git] Filter commit history with git log arguments
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的更多相关文章
- [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 ...
- git 版本(commit) 回退 -- 使用git reset 指令
刚刚提交了三个commit, git reflog显示如下: 最后一个commit在文件末尾加了一行:v3,以此类推: 下面,使用git reset --hard commitID来进行commit回 ...
- Git 学习(三)本地仓库操作——git add & commit
Git 学习(三)本地仓库操作——git add & commit Git 和其他版本控制系统如SVN的一个不同之处就是有暂存区的概念.这在上文已有提及,本文具体说明什么是工作区及暂存区,以及 ...
- git常用命令,学git代码管理
下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote:远程仓库 一. ...
- Git详解之十 Git常用命令
下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote:远程仓库 一. ...
- 10年阿里自动化测试架构师帮您收集的:git常用命令大全以及git原理图【泣血推荐,建议收藏】
一.Git分布式版本控制简介 Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势.本来想着只把最有用.最常用的 Git 命令记下来, ...
- Git学习01 --git add, git commit , git log ,git status, git reset --hard, head
Git官方提供的快速入门教程:https://try.github.io/levels/1/challenges/1 特点:Git极其强大的分支管理:分布式版本 集中式版本控制系统,版本库是集中存放在 ...
- Git删除commit提交的log记录
基于 GitFlow 工作流,可能某个提交(commit)导致了 bug,或者有多个提交需要返工,此时你就会用到删除提交. 接下来的内容都基于下面这张 git log 提交记录图来写. git l ...
- [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 ...
随机推荐
- Java内省
什么是内省? Java语言对bean类属性.事件的一种缺省处理方法,例如类A中有属性name,那我们可以通过getName,setName来得到其值或者设置新的值. 什么是JavaBean? Java ...
- SPOJ 962 Intergalactic Map (从A到B再到C的路线)
[题意]在一个无向图中,一个人要从A点赶往B点,之后再赶往C点,且要求中途不能多次经过同一个点.问是否存在这样的路线.(3 <= N <= 30011, 1 <= M <= 5 ...
- 阿里云主机安装Memcached
http://www.zyuns.com/?page_id=354 前言最近发现阿里云主机在使用中,并发访问量稍大,页面加载速度就很慢.于是学习了一些服务器优化的文章,决定安装Memcached,优化 ...
- 我的WCF之旅(1):创建一个简单的WCF程序
为了使读者对基于WCF的编程模型有一个直观的映像,我将带领读者一步一步地创建一个完整的WCF应用.本应用功能虽然简单,但它涵盖了一个完整WCF应用的基本结构.对那些对WCF不是很了解的读者来说,这个例 ...
- error LNK2001: 无法解析的外部符号 _IID_IDirectDraw7
工程使用了DirectDraw,编译出错 error LNK2001: 无法解析的外部符号 _IID_IDirectDraw7 解决办法是吧dxguid.lib添加到工程中,把lib所在目录添加到工程 ...
- Python脚本控制的WebDriver 常用操作 <二十三> wait
测试用例场景 Wait类的使用场景是在页面上进行某些操作,然后页面上就会出现或隐藏一些元素,此时使用Wait类的until方法来等待这些效果完成以便进行后续的操作.另外页面加载时有可能会执行一些aja ...
- python 遇到 syntaxerror: non-ascii character '/xd6' in file 我 教你解决 (python问题)(转)
遇到标题上的问题,按照我的解决广方案来吧 ===================================== (一) 用记事本创建一个文件ChineseTest.py,默认ANSI: s = ...
- uvalive 4589 Asteroids
题意:给两个凸包,凸包能旋转,求凸包重心之间的最短距离. 思路:显然两个凸包贴在一起时,距离最短.所以,先求重心,再求重心到各个面的最短距离. 三维凸包+重心求法 重心求法:在凸包内,任意枚举一点,在 ...
- C++设计模式——策略模式
策略模式 在GOF的<设计模式:可复用面向对象软件的基础>一书中对策略模式是这样说的:定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换.该模式使得算法可独立于使用它的客户而变化 ...
- BNUOJ-26475 Cookie Selection 堆,线段树等
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26475 题意:每次输入一个操作,如果是数字,那么放入一个容器中,如果是#号,取出当前容器中 ...