[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 -3 // 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 -3 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
相关文章
- Git删除本地分支_idea删除git分支
- 【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )
- 【Git】Git 分支管理 ( 使用 git cherry-pick 命令提取提交记录应用于当前分支 | 创建新分支应用某个提交 | git cherry-pick 冲突处理 )
- Git 2.40 发布,包括 git jump 工具的更新、cat-file 工具的增强以及提高 Windows 上响应速度
- ORA-00293: control file out of sync with redo log ORACLE 报错 故障修复 远程处理
- ORA-00309: log belongs to wrong database ORACLE 报错 故障修复 远程处理
- MySQL Error number: 3840; Symbol: ER_INNODB_REDO_LOG_ARCHIVE_START_TIMEOUT; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-00333: redo log read error block string count string ORACLE 报错 故障修复 远程处理
- ORA-00392: log string of thread string is being cleared, operation not allowed ORACLE 报错 故障修复 远程处理
- ORA-01354: Supplemental log data must be added to run this command ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-010600; Symbol: ER_RPL_LOG_NOT_FOUND_WHILE_COUNTING_RELAY_LOG_SPACE; SQLSTATE: HY000 报错 故障修复 远程处理
- MySQL Error number: MY-010696; Symbol: ER_NDB_BINLOG_STARTING_LOG_AT_EPOCH; SQLSTATE: HY000 报错 故障修复 远程处理
- MySQL Error number: MY-011209; Symbol: ER_AUDIT_LOG_EC_WRITER_FAILED_TO_INIT_COMPRESSION; SQLSTATE: HY000 报错 故障修复 远程处理
- Oracle 视图 DBA_SCHEDULER_JOB_LOG 官方解释,作用,如何使用详细说明
- MySQL日志关闭:一种简单而有效的方法。(mysql关闭log)
- 下使用git在Linux下使用Git:简单易学.(如何在linux)
- Linux环境下编译Git程序指南(linux编译git)
- 连接Linux:Git的使用方法(git连接linux)
- Linux下Git安装指南(linux下git安装)
- 安装Git,轻松掌握Linux之美(linux的git安装)
- 让Oracle支持Git(oracle中的git)
- 利用Oracle Log表优化数据库性能(oracle log表)
- Redis指定Log输出路径的实现方式(redis设置log路径)
- PHPerror_log()将错误信息写入一个文件(定义和用法)
- /var/log/pacct文件导致MySQL启动失败的案例分享
- Node.js中使用Log.io在浏览器中实时监控日志(等同tail-f命令)