星期一, 10月 10, 2011

git log

  • 一般
    • 查看commit歷程
      # git log    
      # git log --stat  // 更動檔案和異動的行數
      # git log <file> //指定檔案
      
      # git diff --name-only // 最近一次的commit有哪些檔案被修改
  • 排版
    • 圖形化commit歷程
      看了沒fu嗎… 用文字圖形化看吧
      git log --graph            //文字圖示版本
      
    • 異動的內容
      即為git diff的內容,太多不寫了,看reference裡有
      $ git log -p
      
    • 一列一版本
      查看版本一目瞭然...... 前提是commit的message要跟範例一樣清楚的話....
      git log --pretty=oneline
      --
      a6b444f570558a5f31ab508dc2a24dc34773825f dammit, this is the second time this has reverted
      49d77f72783e4e9f12d1bbcacc45e7a15c800240 modified index to create refs/heads if it is not 
      9764edd90cf9a423c9698a2f1e814f16f0111238 Add diff-lcs dependency
      e1ba1e3ca83d53a2f16b39c453fad33380f8d1cc Add dependency for Open4
      0f87b4d9020fff756c18323106b3fd4e2f422135 merged recent changes: * accepts relative alt pat
      f0ce7d5979dfb0f415799d086e14a8d2f9653300 updated the Manifest file
    • 特定資料夾
      $ git log fs/           # commits that modify any file under fs/
      
  • 搜尋及過濾
    • 誰異動的,何時,哪個commit
      # git blame filename
      commit    author when
      --------  ---- -------------------------
      394d743f (fish 2013-10-22 17:22:34 +0800  8)     public function getSource()
      394d743f (fish 2013-10-22 17:22:34 +0800  9)     {
      394d743f (fish 2013-10-22 17:22:34 +0800 10)         return "";
      394d743f (fish 2013-10-22 17:22:34 +0800 11)     }
    • 用文字找版本
      $ git log -S'foo()'     # commits that add or remove any file data matching the string 'foo()'
      
    • 最近二周
      $ git log --since="2 weeks ago" # commits from the last 2 weeks
      
      其他還有--after, --until, and --before
    • 不要顯示merge的版本
      $ git log --no-merges
      
其他
$ git log v2.5..        # commits since (not reachable from) v2.5
$ git log test..master  # commits reachable from master but not test
$ git log master..test  # commits reachable from test but not master
$ git log master...test # commits reachable from either test or
                        #    master, but not both
References

沒有留言: