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

  • SEARCH
  • Home
  • 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 9219337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:05:34+00:00 2026-06-18T03:05:34+00:00

I have an issue in git stash. Say for example I have 3 files

  • 0

I have an issue in git stash.

Say for example I have 3 files say a.txt,b.txt & c.txt in the repo and the directory is clean.

Now I’m modifying 2 files among them : a.txt and b.txt.

Now I havent completed my changes in thw two files so I am stashing them by the foll command:

$ git stash save "First Stash"

No if I do a $ git stash list, I get

stash@{0}: On master: First Stash

No if I modify the third text file c.txt and stash that as well as shown:

$ git stash save "Second Stash"

No finally if I do a $git stash list I’m getting the foll result,

stash@{0}: On master: Second stash
stash@{1}: On master: First Stash

The stash number and the messages are mixed up here.What’s going on here?
Now if i pop the stash@{0} I get the first stash contents but the message reversed here which is displaying as Second stash but should have been First Stash.

This is my work flow

admin:stud:/demo/stash_demo> ls
a.txt  b.txt
admin:stud:/demo/stash_demo> echo Hello World >> a.txt
admin:stud:/demo/stash_demo> git stash save "First"
Saved working directory and index state On master: First
HEAD is now at cff03c6 Initail Commit
admin:stud:/demo/stash_demo> echo Hello World >> b.txt
admin:stud:/demo/stash_demo> git stash save "Second"
Saved working directory and index state On master: Second
HEAD is now at cff03c6 Initail Commit

These are my available stashes:

admin:stud:/demo/stash_demo> git stash list
stash@{0}: On master: Second
stash@{1}: On master: First

Now I”ll be trying to apply the stash@{1} which is the first stash and should apply the file a.txt

admin:stud:/demo/stash_demo> git stash apply `stash@{1}`
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   b.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

As seen above I get the most recent changes applied.

And if i try without the ticks “ then it gives me the foll error.

admin:stud:/demo/stash_demo> git stash apply stash@{1}
fatal: ambiguous argument 'stash@1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
  • 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. Editorial Team
    Editorial Team
    2026-06-18T03:05:36+00:00Added an answer on June 18, 2026 at 3:05 am

    Git’s stash is (by default) a LIFO storage.

    By using git stash apply or git stash pop you will always get the last stashed patch (which can be also referenced using stash@{0}, 0 is the index inside the stash). Stashing a new patch will place it on top of other stashed patches, thus increasing their indices by one (stash@{0} will become stash@{1}).

    That said, if you want to apply or pop a patch other than the last one stashed, you need pass its ref to the command:

    $ git stash apply stash@{1}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issue with git pull.I have commited my changes in local repo.
What i have is: a.b.c.d:/x/www/app Now if i issue the command: git clone a.b.c.d:/x/www/app
I ran git pull origin and now I have some issues with merge my
I have this strange issue that my git push origin master and cap deploy
I need help with a git issue. I have managed to create a file
I am getting my feet wet with Git and have the following issue: My
I followed the git guide but I have this strange issue when trying to
I have been wanting to use a git command that saves a stash without
I have been bitten by the Windows/Linux line-ending issue with git. It seems, via
I have a serious issue happened to my git repository. I had 2 branches

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.