Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 46355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:57:11+00:00 2026-05-10T15:57:11+00:00

I frequently use git stash and git stash pop to save and restore changes

  • 0

I frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday, I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I’d like to go back and review yesterday’s stashed changes, but git stash pop appears to remove all references to the associated commit.

I know that if I use git stash then .git/refs/stash contains the reference of the commit used to create the stash. And .git/logs/refs/stash contains the whole stash. But those references are gone after git stash pop. I know that the commit is still in my repository somewhere, but I don’t know what it was.

Is there an easy way to recover yesterday’s stash commit reference?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:57:11+00:00Added an answer on May 10, 2026 at 3:57 pm

    Once you know the hash of the stash commit you dropped, you can apply it as a stash:

    git stash apply $stash_hash 

    Or, you can create a separate branch for it with

    git branch recovered $stash_hash 

    After that, you can do whatever you want with all the normal tools. When you’re done, just blow the branch away.

    Finding the hash

    If you have only just popped it and the terminal is still open, you will still have the hash value printed by git stash pop on screen (thanks, Dolda).

    Otherwise, you can find it using this for Linux, Unix or Git Bash for Windows:

    git fsck --no-reflog | awk '/dangling commit/ {print $3}' 

    …or using PowerShell for Windows:

    git fsck --no-reflog | select-string 'dangling commit' | foreach { $_.ToString().Split(" ")[2] } 

    This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

    The easiest way to find the stash commit you want is probably to pass that list to gitk:

    gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' ) 

    …or see the answer from emragins if using PowerShell for Windows.

    This will launch a repository browser showing you every single commit in the repository ever, regardless of whether it is reachable or not.

    You can replace gitk there with something like git log --graph --oneline --decorate if you prefer a nice graph on the console over a separate GUI app.

    To spot stash commits, look for commit messages of this form:

            WIP on somebranch: commithash Some old commit message

    Note: The commit message will only be in this form (starting with "WIP on") if you did not supply a message when you did git stash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 217k
  • Answers 217k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well, Python 3.0 and 3.1 are already released, so you… May 12, 2026 at 11:27 pm
  • Editorial Team
    Editorial Team added an answer -[NSTask waitUntilExit] is, of course, a blocking call. That means… May 12, 2026 at 11:27 pm
  • Editorial Team
    Editorial Team added an answer I'd say that the single biggest advantage of Cake over… May 12, 2026 at 11:27 pm

Related Questions

I need to to tell which revision/SHA1 of a file was associated with one
I have a simple blog application written in Python, using Django. I use Git
Where I work we need to rethink the way we develop software and keep
I'm contributing to a fairly small open source project hosted on Github. So that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.