How to unstash only certain files?

后端 未结 7 1010
醉梦人生
醉梦人生 2020-12-04 04:29

I stashed my changes. Now I want to unstash only some files from the stash. How can I do this?

7条回答
  •  旧巷少年郎
    2020-12-04 05:03

    First list all the stashes

    git stash list
    

    stash@{0}: WIP on Produktkonfigurator: 132c06a5 Cursor bei glyphicon plus und close zu zeigende Hand ändern
    stash@{1}: WIP on Produktkonfigurator: 132c06a5 Cursor bei glyphicon plus und close zu zeigende Hand ändern
    stash@{2}: WIP on master: 7e450c81 Merge branch 'Offlineseite'
    

    Then show which files are in the stash (lets pick stash 1):

    git stash show 1 --name-only
    
    //Hint: you can also write
    //git stash show stash@{1} --name-only
    

     ajax/product.php
     ajax/productPrice.php
     errors/Company/js/offlineMain.phtml
     errors/Company/mage.php
     errors/Company/page.phtml
     js/konfigurator/konfigurator.js
    

    Then apply the file you like to:

    git checkout stash@{1} -- 
    

    or whole folder:

    git checkout stash@{1} /errors
    

    It also works without -- but it is recommended to use them. See this post.

    It is also conventional to recognize a double hyphen as a signal to stop option interpretation and treat all following arguments literally.

提交回复
热议问题