I have some stashed files in git, but I do not want to git stash pop
it, because sometime it alert merge message, I do not want to do merge in order to see the source code in stashed files, is there a way of doing that?
The Git stash list command will pull up a list of your repository's stashes. Git will display all of your stashes and a corresponding stash index. Now, if you wish to view the contents of a specific stash, you can run the Git stash show command followed by stash@ and the desired index.
Retrieve Stashed Changes To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.
Retrieving stashed changes You can reapply stashed changes with the commands git stash apply and git stash pop . Both commands reapply the changes stashed in the latest stash (that is, stash@{0} ). A stash reapplies the changes while pop removes the changes from the stash and reapplies them to the working copy.
Assuming you want the latest stashed entry,
git show stash@{0}:pathname
Two aspects of this syntax are explained in their respective manual pages:
<rev>:<path>
thing is explained in the gitrevisions(7)
manual page (consider reading it in its entirety — it will teach you certain convenient things to use later on).stash@{<n>}
syntax to access stash entries is explained in the git-stash(1)
manual page.In order to get back a stashed code without remove it of the stash list you can use
git stash apply
to recover the last stashed code, but I believe you just want to see the diff, you can use
git diff stash@{0}
which is a simple command to diff the stashed code at the first position.
Using git stash list
you can take a look at which position
the stashed code you want to see exists and then run git diff stash@{position}
with the proper position
.
EDIT :
As stated in the comments there is another command that could help, if you want to see the whole file in a stashed code you may create a branch with the stashed code and browse at will using the following command
git stash branch <branchname> [<stash>]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With