Export a stash to another computer

前端 未结 9 893
小蘑菇
小蘑菇 2020-12-02 03:43

I need a way to export a stashed change to another computer.

On computer 1 I did

$ git stash save feature

I\'m trying to get the stash

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

    You can apply a patch file (without committing the changes yet) by simply running

    git apply patchfile
    

    Then you can simply create a new stash from the current working directory:

    git stash
    
    0 讨论(0)
  • 2020-12-02 04:21

    How to do export Stash in SourceTree:

    1. Make a new branch "StashTransfer" from a branch where you are going to use your Stash
    2. Apply your stash to it and make a commit

    3. Click on your commit and make a patch from it, take the patch file with you.

    4. Go to a different repository, select the same parent branch which you just used in 1)

    5. Actions / Apply Patch, select Mode: Modify working copy files, push Apply Patch now you have uncommitted modifications from the patch in your current working environment

    6. Make a new Stash for the current repo

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

    The startup command from the original post:

    git stash show -p stash@{x} > patch_file
    

    didn't work for me (for some reason it created unusable patch files). Instead I had to:

    git stash apply stash@{x}
    git commit
    

    for each stash I wanted to transfer. Then, I placed the 'parent' repo within file:/// reach of the 'child' repo, and did the following, for each stash commit:

    git fetch file:///path_to_parent_git && git cherry-pick commit_sha
    git reset --soft HEAD^
    git stash save my_new_stash_on_child
    

    This is more complex but did the trick for me.

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