git 查看当前与上一次version的差异

http://stackoverflow.com/questions/9903541/finding-diff-between-current-and-last-versions

 

 

As pointed out on a comment by amalloy, if by "current and last versions" you mean the last commit and the commit before that, you could simply use

git show
share edit
 
3 
This is what I was looking for. Great answer. – CodeManiak Jan 19 at 22:50
3 
Simpler. This should be the accepted answer. – jbmusso Mar 2 at 9:21
6 
Use git show HEAD~1 to show the last-but-one commit, and git show HEAD~2, etc. for older commits. Show just a single file via git show HEAD~2 my_file. – Florian Brucker Mar 3 at 10:43

Assuming "current version" is the working directory (uncommitted modifications) and "last version" is HEAD (last committed modifications for the current branch), simply do

git diff HEAD

credit for following goes to user Cerran

And if you always skip the staging area with -a when you commit, then you can simply use git diff.

Summary

  1. git diff shows unstaged changes.
  2. git diff --cached shows staged changes.
  3. git diff HEAD shows all changes (both staged and unstaged).

Source: git-diff(1) Manual Page – Cerran

share edit
 
14 
And if you always skip the staging area with -a when you commit, then you can simply use git diff. <1> git diff shows unstaged changes. <2> git diff --cached shows staged changes. <3> git diff HEAD shows all changes (both staged and unstaged). Source: git-diff(1) Manual Page – Cerran Feb 20 '14 at 13:16 
   
This is a good summary. Could be an answer. – user3527975 May 4 at 18:11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值