Undo a git stash

前端 未结 3 1744

I just did a stash in a project that I haven\'t commit. Is there a way to go back to the state before I stashed? How could I do this? I\'ve closed the terminal and my laptop

相关标签:
3条回答
  • 2020-12-07 07:31

    This will also restore the staging directory:

    git stash apply --index
    
    0 讨论(0)
  • 2020-12-07 07:54

    git stash list to list your stashed changes.

    git stash show to see what n is in the below commands.

    git stash apply to apply the most recent stash.

    git stash apply stash@{n} to apply an older stash.

    https://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning

    0 讨论(0)
  • 2020-12-07 07:55

    You can just run:

    git stash pop
    

    and it will unstash your changes.

    If you want to preserve the state of files (staged vs. working), use

    git stash apply --index
    
    0 讨论(0)
提交回复
热议问题