1. 普通查看:git log。输入q退出比较。
  2. $ git log
    commit ca82a6dff817ec66f44342007202690a93763949
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test commit a11bef06a3f659402fe7563abf99ad00de2209e6
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Sat Mar 15 10:31:28 2008 -0700 first commit
  3. 比较最近两次提交的差异。-p:展示每次提交的差异;-2:仅展示最近两次的提交
    $ git log -p -2
    commit ca82a6dff817ec66f44342007202690a93763949
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number diff --git a/Rakefile b/Rakefile
    index a874b73..8f94139 100644
    --- a/Rakefile
    +++ b/Rakefile
    @@ -5,7 +5,7 @@ require 'rake/gempackagetask'
    spec = Gem::Specification.new do |s|
    s.platform = Gem::Platform::RUBY
    s.name = "simplegit"
    - s.version = "0.1.0"
    + s.version = "0.1.1"
    s.author = "Scott Chacon"
    s.email = "schacon@gee-mail.com"
    s.summary = "A simple gem for using Git in Ruby code." commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test diff --git a/lib/simplegit.rb b/lib/simplegit.rb
    index a0a60ae..47c6340 100644
    --- a/lib/simplegit.rb
    +++ b/lib/simplegit.rb
    @@ -18,8 +18,3 @@ class SimpleGit
    end end
    -
    -if $0 == __FILE__
    - git = SimpleGit.new
    - puts git.show
    -end
    \ No newline at end of file
  4. 如果我想看到每次提交的简略的统计信息。git log --stat。所有被修改过的文件、有多少文件被修改了以及被修改过的文件的哪些行被移除或是添加了
    $ git log --stat
    commit ca82a6dff817ec66f44342007202690a93763949
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number Rakefile | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-) commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test lib/simplegit.rb | 5 -----
    1 file changed, 5 deletions(-) commit a11bef06a3f659402fe7563abf99ad00de2209e6
    Author: Scott Chacon <schacon@gee-mail.com>
    Date: Sat Mar 15 10:31:28 2008 -0700 first commit README | 6 ++++++
    Rakefile | 23 +++++++++++++++++++++++
    lib/simplegit.rb | 25 +++++++++++++++++++++++++
    3 files changed, 54 insertions(+)
  5. --pretty:指定使用不同于默认格式的方式展示提交历史。
    1. 可选参数:oneline,short,full,fuller和format

      $ git log --pretty=oneline
      ca82a6dff817ec66f44342007202690a93763949 changed the version number
      085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test
      a11bef06a3f659402fe7563abf99ad00de2209e6 first commit
    2. format参数的应用:定制要显示的记录格式
      $ git log --pretty=format:"%h - %an, %ar : %s"
      ca82a6d - Scott Chacon, 6 years ago : changed the version number
      085bb3b - Scott Chacon, 6 years ago : removed unnecessary test
      a11bef0 - Scott Chacon, 6 years ago : first commit
    3. git log --pertty=format 常用的选项
      %H        提交对象(commit)的完整哈希字串
      
      %h        提交对象的简短哈希字串
      
      %T        树对象(tree)的完整哈希字串
      
      %t        树对象的简短哈希字串
      
      %P        父对象(parent)的完整哈希字串
      
      %p        父对象的简短哈希字串
      
      %an       作者(author)的名字
      
      %ae       作者的电子邮件地址
      
      %ad       作者修订日期(可以用 --date= 选项定制格式)
      
      %ar       作者修订日期,按多久以前的方式显示
      
      %cn       提交者(committer)的名字
      
      %ce       提交者的电子邮件地址
      
      %cd       提交日期
      
      %cr       提交日期,按多久以前的方式显示
      
      %s        提交说明
    4. 结合--graph方便查看分支提交的信息
      $ git log --pretty=format:"%h %s" --graph
      * 2d3acf9 ignore errors from SIGCHLD on trap
      * 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit
      |\
      | * 420eac9 Added a method for getting the current branch.
      * | 30e367c timeout code and tests
      * | 5a09431 add timeout protection to grit
      * | e1193f8 support for heads with slashes in them
      |/
      * d6016bc require time for xmlschema
      * 11d191e Merge branch 'defunkt' into local
  6. git log的常用选项
    -p                        按补丁格式显示每个更新之间的差异。
    
    --stat                    显示每次更新的文件修改统计信息。
    
    --shortstat               只显示 --stat 中最后的行数修改添加移除统计。
    
    --name-only               仅在提交信息后显示已修改的文件清单。
    
    --name-status             显示新增、修改、删除的文件清单。
    
    --abbrev-commit           仅显示 SHA-1 的前几个字符,而非所有的 40 个字符。
    
    --relative-date           使用较短的相对时间显示(比如,“2 weeks ago”)。
    
    --graph                   显示 ASCII 图形表示的分支合并历史。
    
    --pretty                  使用其他格式显示历史提交信息。选项包括 oneline,short,full,fuller 和 format(后跟指定格式)。 
  7. 限制输出
    1. 限制输出的选项

      -(n)                  仅显示最近的 n 条提交
      
      --since, --after      仅显示指定时间之后的提交。
      
      --until, --before     仅显示指定时间之前的提交。
      
      --author              仅显示指定作者相关的提交。
      
      --committer           仅显示指定提交者相关的提交。
      
      --grep                仅显示含指定关键字的提交
      
      -S                    仅显示添加或移除了某个关键字的提交
    2. 限制输出的运用。查看 Git 仓库中,2017 年 愚人节期间,jeff 提交的但未合并的测试文件,可以用下面的查询命令:
      $ git log --pretty="%h - %s" --author=jeff --since="2017-03-31" --before="2017-04-02" --no-merges
      5610e3b - Fix testcase failure when extended attributes are in use
      acd3b9e - Enhance hold_lock_file_for_{update,append}() API
      f563754 - demonstrate breakage of detached checkout with symbolic link HEAD
      d1a43f2 - reset --hard/read-tree --reset -u: remove unmerged new paths
      51a94af - Fix "checkout --track -b newbranch" on detached HEAD
      b0ad11e - pull: allow "git pull origin $something:$current_branch" into an unborn branch

git杂记-查看历史提交的更多相关文章

  1. git 命令 查看历史提交 git log

    怎么理解git commit 命令 git commit 相当于 我们虚拟机快照操作,每次执行commit命令 相当于对本地仓库做一次快照,保存了当时仓库的状态, git commit -m 加上的& ...

  2. git删除所有历史提交记录,只留下最新的干净代码

    git删除所有历史提交记录,只留下最新的干净代码 1.Checkout git checkout --orphan latest_branch 2. Add all the files git add ...

  3. Git 删除所有历史提交记录方法

    Git 删除所有历史提交记录方法 切换分支 git checkout --orphan latest_branch 添加所有文件 git add -A 提交更改 git commit -am &quo ...

  4. GIT入门笔记(8)-- 查看历史提交记录/根据版本号回到过去或未来

    在Git中,用HEAD表示当前版本,也就是最新的提交版本, 上一个版本就是HEAD^, 上上一个版本就是HEAD^^, 往上100个版本写100个^比较容易数不过来,所以写成HEAD~100. Git ...

  5. 『现学现忘』Git基础 — 24、Git中查看历史版本记录

    目录 1.查看详细的历史版本记录 2.简化显示历史版本记录 3.历史版本记录常用操作 (1)指定查看最近几次提交的内容 (2)以简单图形的方式查看分支版本历史 (3)翻页与退出 4.查看分支相关的版本 ...

  6. git rebase修改历史提交内容

    目录 简述 解决过程 简述 git提交历史中有一次提交的内容是有问题,因为每隔一段时间就要发一次版本,所以必须修改这次提交的内容,以便其不影响已经发布的版本. 大概是这样子的 A --- B ---- ...

  7. Git彻底删除历史提交记录的方法

    有时候我们可能会遇到git提交错误的情况,比如提交了敏感的信息或者提交了错误的版本.这个时候我们想将提交到代码库的记录删除,我们要怎么做呢? 首先,我们需要找到我们需要回滚到的提交点的hash,可以使 ...

  8. Git 游离的HEAD detached HEAD git reflog 查看所有提交的 id

  9. Git使用四:查看工作状态和历史提交

    查看当前的工作状态:git status On branch master:现在位于master分支里面nothing to commit, working tree clean:没有需要提交的文件, ...

随机推荐

  1. C++与C的区别二

    1. new,delete的局部重载: #include <iostream> using namespace std; ; class myclass { public: myclass ...

  2. 这是一次 docker 入门实践

    前言 其实接触 docker 也有一段时间了,但是一直没有做下总结,现在网上关于 docker 的介绍也有很多了,本着好记性不如烂笔头的原则,还是自己再记录一波吧. 实现目标 安装 docker ce ...

  3. iOS 时区获取问题

    时区缩写 UTC, CST, GMT, CEST 以及转换 UTC是协调世界时(Universal Time Coordinated)英文缩写,是由国际无线电咨询委员会规定和推荐,并由国际时间局(BI ...

  4. 第一站:CLion安装教程与环境配置

    原文来自:http://www.sunmey.cn/thread-129-1-1.html 本人:找了很久才找到的CLion安装教程与环境配置,这里分享给大家~ 这里要说明的一点是CLion是要钱的, ...

  5. C#生成验证码类

    using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;us ...

  6. create-react-app安装出错问题解决

    在用create-react-app的时候 报错 错误如下图: 在SF上查到说是或许是因为国内npm拉去资源,拉去不到的问题,可以试着从解决创建create-react-app慢的方法着手: 解决方法 ...

  7. winform MD5加密

    byte[] result = Encoding.Default.GetBytes(this.tbPass.Text.Trim());    //tbPass为输入密码的文本框MD5 md5 = ne ...

  8. JavaScript设计模式-18.享元模式

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. Integer源码分析

    Integer中包含了大量的static方法. 1.分析Integer的缓存机制:首先定义了一个缓存区,IntegerCache,其实就是一个Integer数组cache[],它默认存储了从-128~ ...

  10. [Mysql]——用户管理

    登录和退出 > mysql  -h 参数后面接hostname或者hostIP -P 参数后面接Mysql服务的端口号,通过指定的端口号来进行连接 -u 参数后面接username用户名 -p ...