好好爱自己!

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
shareedit
 
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

shareedit
 
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
posted @   立志做一个好的程序员  阅读(2082)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现

不断学习创作,与自己快乐相处

点击右上角即可分享
微信分享提示