git - 查看 Git 中 1 个特定 stash 文件的差异内容

标签 git diff git-stash git-show

假设我有 2 个 stash 文件:

$ git stash show

a.txt | 2 +-
b.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

我可以查看存储的完整差异:

diff --git a/a.txt b/a.txt
index bc56c4d..a688182 100644
--- a/a.txt
+++ b/a.txt
@@ -1 +1 @@
-Foo
+Baz
diff --git a/b.txt b/b.txt
index ebd7525..4105321 100644
--- a/b.txt
+++ b/b.txt
@@ -1 +1 @@
-Bar
+Qux

更多文件会使输出变得困惑,因此我只想查看 1 个特定文件。但是,手册似乎说没有使用文件名参数的选项:

NAME
       git-stash - Stash the changes in a dirty working directory away

SYNOPSIS
       ...
       git stash show [<stash>]
       ...

有没有办法只查看 1 个特定 stash 文件的差异内容?

最佳答案

构建于 How would I extract a single file (or changes to a file) from a git stash?你可以:

git diff stash@{0}^! --a.txt

关于git - 查看 Git 中 1 个特定 stash 文件的差异内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58213381/

相关文章:

php - 比较对象属性并在 PHP 中显示差异

git - stash , pull 和 pop 与提交和 pull --rebase之间有重要区别吗?

git - 多个 ssh key

git - 在 U 盘上使用 GIT 获取 "travelling code"

Git diff 仅显示已修改的行

assembly - 比较两个二进制文件

git - 是什么导致 git-apply "corrupt patch?"

git - 在 git 分支中“固定”文件的特定版本

git-stash 更改而不恢复

git - 长期保存 git stash 修订版