Export a stash to another computer

前端 未结 9 910
小蘑菇
小蘑菇 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: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.

提交回复
热议问题