zoukankan      html  css  js  c++  java
  • git杂记-查看历史提交

    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
  • 相关阅读:
    iOS controller 和 window 图层
    iOS CGAffineTransform 仿射变换
    iOS UIButton的UIEdgeInsets
    iOS UI的动态布局
    iOS 栅格动态布局
    iOS 系统键盘几个类型
    iOS 金融类高精度处理
    Sublime Text (崇高文本)
    iOS 静态库——制作bundle
    iOS 静态库——制作Framework
  • 原文地址:https://www.cnblogs.com/oufeng/p/6657021.html
Copyright © 2011-2022 走看看