This write-up will discuss:
- How to Show Stored Changes of Individual Stash?
- How to Show Stored Changes With the Patch Format of Individual Stash?
- How to Show All Stash Changes Including Untracked Files of Individual Stash?
- How to Show Only Untracked Changes of Individual Stash?
How to Show Stored Changes of Individual Stash?
To display the stored changes of individual stash, first, view the available stashes in the repository:
It can be seen that there is only one stash in the repository:
Then, run the below-provided command along with the particular stash reference to display its changes:
The below output shows the list of (tracked) files stored in the stash:
How to Show Stored Changes With the Patch Format of Individual Stash?
Utilize the below-provided command along with the “-p” flag to view stash changes with the patch format:
The changes of files stored in the stash can be seen in the given output:
How to Show All Stash Changes Including Untracked Files of Individual Stash?
The simple “git stash show stash@{0}” command only displays the tracked file’s stash changes. In order to view the untracked files of individual stash, utilize the “-u” option in the same command:
Here, it can be seen that the following output shows the untracked file’s changes also, i.e., “f1.txt”:
Alternatively, users can utilize the “–include-untracked” option to show the untracked file’s changes:
How to Show Only Untracked Changes of Individual Stash?
Sometimes, users just want to display the untracked file changes of a particular stash. In this situation, the “–only-untracked” option can be utilized with the previous command:
We have efficiently explained different ways to show individual stash in Git.
Conclusion
There are different ways to show or display the stash in Git, such as if the user only wants to view the stored changes of an individual stash, the “git stash show stash@{<reference-no>}” command can be used. For the patch format, utilize the “-p” option with the same command. Furthermore, “-u” and “–include-untracked” options are used to display all the changes including the untracked file changes of individual stash. Moreover, you can view only the untracked file’s changes of the stash using the “–only-untracked” option. This write-up explained the different methods to display an individual stash.