Display Patch of Stash
If you want to see the changes introduced by a specific stash entry in patch format, you can use the -p or –patch option with the git stash show command:
git stash show -p <stash_index>
This command displays the changes as a patch, making it easier to review the modifications introduced by the stash.
Example Usage:
git stash list
Output:
csharpstash@{0}:
WIP on master: 1234567 Commit message 1stash@{1}:
WIP on feature: 9876543 Commit message 2
git stash show 0
Output:
file1.txt | 10 ++++++++++
1 file changed, 10 insertions(+)
Output:
diff --git a/file2.txt b/file2.txt
index abcdefg..hijklmn 100644
--- a/file2.txt
+++ b/file2.txt
@@ -1,4 +1,5 @@
This is line 1
This is line 2
+This is a new line added in the stash
This is line 3
This is line 4
How to List and Show the Git Stash History?
In Git, the stash is a powerful feature that allows developers to temporarily store changes that are not ready to be committed. Stashing is particularly useful when you need to switch branches or apply fixes to another part of the codebase without committing to unfinished work. Git provides commands to list and show the stash history, enabling you to manage and retrieve stashed changes effectively. In this guide, we’ll explore how to list and show the Git stash history.
Table of Content
- How to List and Show the Git Stash History?
- List Stash Entries
- Show Stash Details
- Display Patch of Stash
- Conclusion