gpt4 book ai didi

git - git diff 是比较索引和工作副本还是最后一次提交和工作副本?

转载 作者:太空狗 更新时间:2023-10-29 14:31:53 25 4
gpt4 key购买 nike

在 git reference , 据称

A simple git diff will display in unified diff format (a patch) what code or content you've changed in your project since the last commit that are not yet staged for the next commit snapshot.

我所做的是提交一个包含文本 A 的文件。然后我将该文件中的文本从 A 更改为 B 并且上演它(没有提交)。最后,我将文件的内容更改为 C。现在,当我运行 git diff 时,它显示了 BC 之间的区别。但我想看看 AC 之间的区别。我该怎么做?

最佳答案

如果你想检查其他事物之间的差异,例如看下面的例子:

你可以跑

git diff HEAD^       #check against parent of last commit
git diff HEAD^^ #check against grandparent of last commit
git diff HEAD~5 #check against 5 commits ago, 5 can be replaced with any number
git diff HEAD^..HEAD #check second most recent commit against most recent
git diff SHA1 SHA2 #check difference between two pre-defined commits
git diff --staged #check staged vs current index (HEAD)

您也可以根据时间变化来执行此操作,但这更高级一些。

关于git - git diff 是比较索引和工作副本还是最后一次提交和工作副本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38481103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com