美文网首页
Git查看提交历史

Git查看提交历史

作者: 走过分叉路 | 来源:发表于2019-12-18 10:39 被阅读0次

    不带参数的log命令

    $ git log
    commit ca82a6dff817ec66f44342007202690a93763949 (HEAD -> master, origin/master, origin/HEAD)
    Author: Scott Chacon <schacon@gmail.com>
    Date:   Mon Mar 17 21:52:11 2008 -0700
    
        changed the verison number
    
    commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
    Author: Scott Chacon <schacon@gmail.com>
    Date:   Sat Mar 15 16:40:33 2008 -0700
    
        removed unnecessary test code
    
    commit a11bef06a3f659402fe7563abf99ad00de2209e6
    Author: Scott Chacon <schacon@gmail.com>
    Date:   Sat Mar 15 10:31:28 2008 -0700
    
        first commit
    
    

    git log --prety=format常用的选项

    image.png

    示例:显示作者的电子邮件地址,提交者的名字, 提交说明

    $ git log --pretty=format:"%ae, %cn, %s"
    schacon@gmail.com, Scott Chacon, changed the verison number
    schacon@gmail.com, Scott Chacon, removed unnecessary test code
    schacon@gmail.com, Scott Chacon, first commit
    

    git log的常用选项

    image.png

    示例:显示新增、修改、删除的文件清单

    $ git log --name-status
    commit ca82a6dff817ec66f44342007202690a93763949 (HEAD -> master, origin/master, origin/HEAD)
    Author: Scott Chacon <schacon@gmail.com>
    Date:   Mon Mar 17 21:52:11 2008 -0700
    
        changed the verison number
    
    M       Rakefile
    
    commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
    Author: Scott Chacon <schacon@gmail.com>
    Date:   Sat Mar 15 16:40:33 2008 -0700
    
        removed unnecessary test code
    
    M       lib/simplegit.rb
    
    commit a11bef06a3f659402fe7563abf99ad00de2209e6
    Author: Scott Chacon <schacon@gmail.com>
    Date:   Sat Mar 15 10:31:28 2008 -0700
    
        first commit
    
    A       README
    A       Rakefile
    A       lib/simplegit.rb
    

    git log限制输出长度

    限制git log输出的选项 image.png

    示例:提交对象的简短的哈希字符串 - 提交说明,过滤时间是2006-10-01到2018-11-01期间,提交但未合并的记录

    $ git log --pretty="%h - %s" --since="2006-10-01" --before="2018-11-01" --no-merges -- t/
    

    相关文章

      网友评论

          本文标题:Git查看提交历史

          本文链接:https://www.haomeiwen.com/subject/nmvynctx.html