Git笔记

如何查看提交中是否包含重命名或复制?

$ git log --name-status -M -C -1  
commit c04ecb6edd602a8463b5239a5fde900b2b3 (HEAD -> 256818)
Author: gqqnbig <gqqnbig@gmail.com>
Date: Wed Nov 15 10:45:17 2017 -0800

Extract controls from ReviewApplication.aspx so that they can be reused in viewSummary.aspx.
BugzID: 256818

M Xpress/LoanApp/App_LocalResources/ReviewApplication.aspx.pl.resx
M Xpress/LoanApp/App_LocalResources/ReviewApplication.aspx.resx
M Xpress/LoanApp/ReviewApplication.aspx
M Xpress/LoanApp/ReviewApplication.aspx.vb
A Xpress/inc/App_LocalResources/ReviewApplication.ascx.resx
C067 Xpress/LoanApp/ReviewApplication.aspx Xpress/inc/ReviewApplication.ascx
A Xpress/inc/ReviewApplication.ascx.vb

这个命令要求查看最近一条提交(-1),并启用重命名(-M)和复制(-C)检测。

结果显示ReviewApplication.ascx是ReviewApplication.aspx的复制,相似度67%。

如何查看复制或移动的文件的diff?

如果只查看某一提交里某一文件的diff,则运行

git difftool c04ecb^:Xpress/LoanApp/ReviewApplication.aspx c04ecb:Xpress/inc/ReviewApplication.ascx

如果查看某一提交的所有文件的diff,则运行

git difftool -M -C --find-copies-harder c04ecb^ c04ecb

发表评论

电子邮件地址不会被公开。

:wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O 8)