Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git diff 比较不同版本的差异

Git 比较不同版本文件差异的常用命令格式:

git diff                                       查看尚未暂存的文件更新了哪些部分

git diff filename 查看尚未暂存的某个文件更新了哪些

git diff –cached                    查看已经暂存起来的文件和上次提交的版本之间的差异

git diff –cached filename 查看已经暂存起来的某个文件和上次提交的版本之间的差异

git diff ffd98b291e0caa6c33575c1ef465eae661ce40c9 b8e7b00c02b95b320f14b625663fdecf2d63e74c 查看某两个版本之间的差异

git diff ffd98b291e0caa6c33575c1ef465eae661ce40c9:filename b8e7b00c02b95b320f14b625663fdecf2d63e74c:filename 查看某两个版本的某个文件之间的差异
@fengxuangit
Copy link

fengxuangit commented Jul 12, 2016

nice

@lidasong
Copy link

lidasong commented Sep 21, 2016

@irwenqiang
Copy link

irwenqiang commented Nov 4, 2016

cool

@jieniu
Copy link

jieniu commented Feb 10, 2017

还有git diff commit

@AceMood
Copy link

AceMood commented Mar 8, 2017

git diff {path} 如果path的文件没有暂存的话(untrack) 我看是没有diff信息的呀,只有之前加入到暂存区且本地modify之后没有再次加入的文件才会有diff吧

@iguoli
Copy link

iguoli commented Jun 5, 2017

对我非常有用,感谢!

@DengXuening
Copy link

DengXuening commented Oct 4, 2017

nice

@fuckthe-code
Copy link

fuckthe-code commented Nov 27, 2017

very good

@qingfeng825
Copy link

qingfeng825 commented Dec 17, 2017

git version2.6.4: "-"应为“”“--”
git diff -cached应为git diff --cached

@YellowTulipShow
Copy link

YellowTulipShow commented Dec 26, 2017

good

@chensixiu
Copy link

chensixiu commented Feb 27, 2018

6年前的笔记,对6年后的我来说还是有用的

@djlxiaoshi
Copy link

djlxiaoshi commented Mar 21, 2018

终于弄清楚了,好多次来了一个git diff 发现什么都没有,都不知道是什么情况

@jiapengwen
Copy link

jiapengwen commented Aug 30, 2018

--cached

@lbq1223android
Copy link

lbq1223android commented Aug 12, 2019

7年前的笔记 现在看来 还是很棒!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment