本文翻译自:How to see the changes in a Git commit?

When I do git diff COMMIT I see the changes between that commit and HEAD (as far as I know), but I would like to see the changes that were made by that single commit. 当我执行git diff COMMIT我看到了该提交和HEAD之间的变化(据我所知),但我希望看到该单个提交所做的更改。

I haven't found any obvious options on diff / log that will give me that output. 我没有在diff / log上找到任何明显的选项,它会给我输出。


#1楼

参考:https://stackoom.com/question/1Bh7u/如何查看Git提交中的更改


#2楼

To see the diff for a particular COMMIT hash: 要查看特定COMMIT哈希的差异:

git diff COMMIT~ COMMIT will show you the difference between that COMMIT 's ancestor and the COMMIT . git diff COMMIT~ COMMIT将显示COMMIT的祖先和COMMIT之间的区别。 See the man pages for git diff for details about the command and gitrevisions about the ~ notation and its friends. 有关命令和gitrevisions有关~符号及其朋友的详细信息,请参阅git diff的手册页。

Alternatively, git show COMMIT will do something very similar. 或者, git show COMMIT会做一些非常相似的事情。 (The commit's data, including its diff - but not for merge commits.) See the git show manpage . (提交的数据,包括它的差异 - 但不适用于合并提交。)请参阅git show联机帮助页 。


#3楼

As mentioned in " Shorthand for diff of git commit with its parent? ", you can also use git diff with: 正如“ 使用其父级的git提交的差异的简写? ”中所提到的,你也可以使用git diff

git diff COMMIT^!

or 要么

git diff-tree -p COMMIT

With git show, you would need (in order to focus on diff alone) to do: 使用git show,你需要(为了专注于diff)来做:

git show --color --pretty=format:%b $COMMIT

The COMMIT parameter is a commit-ish : COMMIT参数是commit-ish :

A commit object or an object that can be recursively dereferenced to a commit object. 甲commit对象或一个对象可以被递归地解除引用到一个提交对象。 The following are all commit-ishes: a commit object, a tag object that points to a commit object, a tag object that points to a tag object that points to a commit object, etc. 以下是所有承诺,ishes:提交对象, 标签对象指向一个commit对象,指向一个指向commit对象等标签对象标签对象

See gitrevision "SPECIFYING REVISIONS" to reference a commit-ish. 请参阅gitrevision“SPECIFYING REVISIONS”以引用commit-ish。
See also " What does tree-ish mean in Git? ". 另请参阅“ Git中树的含义是什么? ”。


#4楼

From the man page for git-diff(1) : 从git-diff(1)的手册页:

git diff [options] [<commit>] [--] [<path>…]
git diff [options] --cached [<commit>] [--] [<path>…]
git diff [options] <commit> <commit> [--] [<path>…]
git diff [options] <blob> <blob>
git diff [options] [--no-index] [--] <path> <path>

Use the 3rd one in the middle: 使用中间的第3个:

git diff [options] <parent-commit> <commit>

Also from the same man page, at the bottom, in the Examples section : 同样来自同一手册页,位于底部的示例部分 :

$ git diff HEAD^ HEAD      <3>

Compare the version before the last commit and the last commit. 比较上次提交和最后一次提交之前的版本。

Admittedly it's worded a little confusingly, it would be less confusing as 不可否认,它的措辞有点令人困惑,因为它不会那么令人困惑

Compare the most recent commit with the commit before it. 将最近的提交与之前的提交进行比较。


#5楼

git difftool COMMIT^ <commit hash>

is also possible if you have configured your difftool. 如果您配置了difftool,也可以使用。

See here how to configure difftool Or the manual page here 看到这里如何配置difftool或手动页面点击这里

Additionally you can use git diff-tree --no-commit-id --name-only -r <commit hash> to see which files been changed/committed in a give commit hash 另外,您可以使用git diff-tree --no-commit-id --name-only -r <commit hash>来查看在给定提交哈希中更改/提交的文件


#6楼

The following seems to do the job; 以下似乎可以胜任这项工作; I use it to show what has been brought in by a merge. 我用它来显示合并带来了什么。

git whatchanged -m -n 1 -p <SHA-1 hash of merge commit>

如何查看Git提交中的更改?相关推荐

  1. 教你如何查看 Git 提交中发生了什么变化

    Git 提供了几种方式可以帮你快速查看提交中哪些文件被改变. 如果你每天使用 Git,应该会提交不少改动.如果你每天和其他人在一个项目中使用 Git,假设 每个人 每天的提交都是安全的,你会意识到 G ...

  2. 从 Git 提交中删除文件

    问: 如何从最新提交中删除文件? 答1: huntsbot.com – 程序员副业首选,一站式外包任务.远程工作.创意产品分享订阅平台. 我认为这里的其他答案是错误的,因为这是一个将错误提交的文件从上 ...

  3. commit git 删除文件夹_从Git提交中删除文件

    现有的答案都在谈论从上一次提交中删除不需要的文件. 如果要从旧提交(甚至推送)中删除不需要的文件,并且不想创建新提交,则由于该操作,这是不必要的: 1. 查找您要文件符合的提交. git checko ...

  4. git提交中E325: ATTENTION或E325: 注意 的解决方法

    问题引入 首先看下图,在git提交.编辑.合并等过程中,如果没有将指令进行完就将git窗口关闭有时会出现这样的界面. 原因分析 git在指令意外中断时,一般会有一个缓存的机制,它会记住上次中断的问题. ...

  5. 在Mac中使用dotnet || mac中查看路径 || mac中永久性更改系统路径

    这里写自定义目录标题 在Mac中使用dotnet 1. 下载.net包 2. 可能出现的问题(bash中) 3. 找到问题 4. 解决问题:修改路径 5. 结果 在Mac中使用dotnet 1. 下载 ...

  6. 修改idea中git提交的作者(Author)和邮箱

    修改idea中git commit时的作者(Author)和邮箱 : 1.查看git提交的作者和邮箱 //查看作者 git config user.name //查看邮箱 git config use ...

  7. Git 提交代码单词

    Git  分布式的版本控制软件 (优点 1.快照 切换版本快  2.大部分操作可以离线,不用网) 红:工作区是新的 绿:工作区存入暂存区,暂未提交至工作区 白色:工作区和仓库一致 1. Git 中的三 ...

  8. Git系列(2)pycharm使用git提交代码

    1.查看git日志 2.文件更改 添加一部分信息后文件会变蓝 新创建一个文件夹 会提问要不要加入到Git中 如果选择cancel文件夹会继续是红色的然后不加到Git仓库 选择add则文件名变绿 3.提 ...

  9. yubikey复制_如何在Windows上使用YubiKey NEO和GPG和Keybase设置Signed Git提交

    yubikey复制 This week in obscure blog titles, I bring you the nightmare that is setting up Signed Git ...

最新文章

  1. SpringMVC + MyBatis整合 【转】
  2. 设计模式-扩展-父类对子类的要求
  3. 全球及中国甲醇催化剂行业前景动态与市场需求调研报告2022版
  4. 第四范式陈雨强获评首届世界人工智能大会云帆奖 | 2020WAIC
  5. 20应用统计考研复试要点(part28)--简答题
  6. js循环获取table中的值
  7. java 生成token代码_java token生成和校验的实例代码
  8. C语言的printf一些骚操作
  9. easyui181版本使用记录
  10. 点分十进制ip地址的理解
  11. java mina框架实例_MINA框架简介和一个简单的例子
  12. CST微波工作室学习笔记—14.天线设计实例
  13. 产品经理—怎么用KANO模型给众多需求进行优先级排序?
  14. Pintech品致钳形交直流电流探头的主要功能
  15. 哪吒之魔童降世视听语言影评_动画电影《哪吒之魔童降世》艺术语言分析
  16. JavaScript—有关如何实现全选/全不选、检查是否选中了复选框。
  17. vue里使用echarts画世界地图
  18. ROS2 基础概念 话题
  19. Android 基于Zxing的扫码功能实现(二)
  20. Vivado2022.2安装教程

热门文章

  1. 网站防盗链的配置之apache
  2. vc++6.0工具栏自绘按钮程序
  3. php 基础系列之 php快速入门
  4. CCF CSP 201604-1 折点计数
  5. BootStrap Table和Mybatis Plus实现服务端分页
  6. android 生成签名和SHA1签名信息
  7. django_4:数据库0——配置数据库
  8. js+css3实现旋转效果
  9. win10无法新建文件夹怎么办 win10右键新建菜单设置方法
  10. 软件需求规格说明书(网络助手)