Is it possible to preview stash contents in git?

后端 未结 16 1712
后悔当初
后悔当初 2020-12-02 03:34

I often put work away for later, then other stuff comes along, and a few weeks later, I want to inspect the stash, and find out what changes it would make if I applied it to

相关标签:
16条回答
  • 2020-12-02 04:16

    You can view all stashes' list by the following command:

    $ git stash list
    
    stash@{0}: WIP on dev: ffffd4d75 spelling fix
    
    stash@{1}: WIP on dev: 40e65a8 setting width for messages
    
    ......
    
    ......
    
    ......
    
    
    stash@{12}: WIP on dev: 264fdab added token based auth
    

    Newest stash is the first one.

    You can simply select index n of stash provided in the above list and use the following command to view stashed details

    git stash show -p stash@{3}
    

    Similarly,

    git stash show -p stash@{n}
    

    You can also check diff by using the command :

    git diff HEAD stash@{n} -- /path/to/file
    
    0 讨论(0)
  • 2020-12-02 04:17

    View list of stashed changes

    git stash list
    

    For viewing list of files changed in a particular stash

    git stash show -p stash@{0} --name-only
    

    For viewing a particular file in stash

    git show stash@{0} path/to/file
    
    0 讨论(0)
  • 2020-12-02 04:17

    You can review the stashed changes in VSCode with gitlen extension

    screenshot of gitlen stashes

    0 讨论(0)
  • 2020-12-02 04:18

    Beyond the gitk recommendation in Is it possible to preview stash contents in git? you can install tig and call tig stash. This free/open console program also allows you to choose which stash to compare

    0 讨论(0)
提交回复
热议问题