这些git diff命令有什么区别? [英] What are the differences between these git diff commands?

查看:110
本文介绍了这些git diff命令有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下git命令有什么不同?

What are the differences between the following git commands?


  1. git diff HEAD

  2. git diff HEAD ^

  3. git diff - 缓存或同义词 git diff --staged

  4. git diff

  1. git diff HEAD
  2. git diff HEAD^
  3. git diff --cached or the synonym git diff --staged
  4. git diff


推荐答案


  1. git diff HEAD - 显示自上次提交以来发生的变化。
  2. 显示自 之前自最近一次提交以来发生了哪些变化。 通过 git add 但尚未提交的内容添加到索引中的内容。
  3. git diff - 通过 git add 显示已更改但尚未添加到索引中的内容。
  1. git diff HEAD - Shows what has changed since the last commit.
  2. git diff HEAD^ - Shows what has changed since the commit before the latest commit.
  3. git diff --cached - Show what has been added to the index via git add but not yet committed.
  4. git diff - Show what has changed but hasn't been added to the index yet via git add.

看起来像这样:

It looks like this:

     Working
    Directory  <----+--------+------+
        |           |        |      |    
        |           |        |      |
        V           |        |      |    
    "git add"       |        |      |    
        |         diff       |      |    
        |           |        |      |    
        V           |        |      |    
     Index     <----+    diff HEAD  |            
        |           |        |      |       
        |           |        |      |
        V           |        |      |       
  "git commit"      |        |      |
        |     diff --cached  |      |
        |     diff --staged  |      |
        V           |        |      |
      HEAD     <----+--------+      |
        |                           |
        |                        diff HEAD^
        V                           |
previous "git commit"               |
        |                           |
        |                           |
        V                           |
      HEAD^    <--------------------+

这篇关于这些git diff命令有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆