使用git_blame定位修改程式碼歷史
阿新 • • 發佈:2018-12-26
使用git blame定位修改程式碼歷史
git blame定義
git-blame - Show what revision and author last modified each line of a file
文件地址: https://git-scm.com/docs/git-blame
檢視整個檔案修改歷史
git blame file
顯示格式為: commit id + author + commit date
$ git blame src/main/java/com/github/***/cpone/MyThread.java
0a497a6e ( m***e 2018-12-09 10:57:05 +0800 1) package com.github.white.cpone;
0a497a6e (m***e 2018-12-09 10:57:05 +0800 2)
0a497a6e (m***e 2018-12-09 10:57:05 +0800 3) public class MyThread extends Thread {
0a497a6e (m***e 2018-12-09 10:57:05 +0800 4)
0a497a6e (m***e 2018-12-09 10:57:05 +0800 5)
檢視檔案中某個程式碼段修改歷史
git blame -L start,end file
$ git blame -L 22,28 src/main/java/com/github/***/cpone/MyThread.java
f5b5b4b4 (m***e 2018-12-09 14:43:29 +0800 23) System.out.println("程序catch中...");
f5b5b4b4 (m***e 2018-12-09 14:43:29 +0800 25) System.out.println("catch...");
0a497a6e (m***e 2018-12-09 10:57:05 +0800 26) Thread.currentThread( ).interrupt();