【问题标题】:View diff contents of 1 specific stashed file in Git在 Git 中查看 1 个特定隐藏文件的差异内容
【发布时间】:2019-10-03 06:25:07
【问题描述】:

假设我有 2 个隐藏文件:

$ 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 个特定隐藏文件的差异内容?

【问题讨论】:

    标签: git diff git-stash git-show


    【解决方案1】:

    How would I extract a single file (or changes to a file) from a git stash? 为基础,您可以:

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

    【讨论】:

    • 完美,正是我需要的。
    猜你喜欢
    • 2017-07-10
    • 2021-04-16
    • 2021-03-12
    • 2016-09-20
    • 1970-01-01
    • 1970-01-01
    • 2022-10-25
    • 2021-04-23
    • 2012-07-28
    相关资源
    最近更新 更多