how to check the source code of stashed files without pop them in git?

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?

  • git remove file from stash
  • Git keep some local changes clean but do not push them
  • git stash pop: avoiding stash drop and un-staging steps
  • Is it possible to delete a single file (i.e the diff of one file) from git stash with several files
  • Git stash twice
  • Undoing accidental git stash pop
  • In git, is there a way to show untracked stashed files without applying the stash?
  • Is it possible to choose a git stash when they're described by the date stashed?
  • 2 Solutions collect form web for “how to check the source code of stashed files without pop them in git?”

    Assuming you want the latest stashed entry,

    git show stash@{0}:pathname

    Two aspects of this syntax are explained in their respective manual pages:

    • The <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).
    • The 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>]
    Git Baby is a git and github fan, let's start git clone.