Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy the list of stashes from one clone or folder to another

I have two git clones of same remote repository. I have created several stashes in clone A and now want to move those stashes to clone B.

[Clone A] ---- stashes ---> [Clone B]

One workaround I could think of is creating branch for each stash and push that branch to remote through Clone A, and then pull these branches into Clone B. But this is not I would prefer to do.

Could anyone suggest any easier and cleaner way (like copying) of doing it?

like image 655
Saurav Sahu Avatar asked Nov 07 '22 20:11

Saurav Sahu


1 Answers

You should be able to copy over .git/refs/stash for the latest stash and .git/logs/refs/stash for all others up in the stack. Actually you should even be able to pull refs/stash for the latest one I think.

But this will probably not work correctly, as the commit objects for the stashes will not be present in the copy target. You can maybe set up .git/objects/info/alternates so that missing objects will be searched in your A repository to make the copy work in the target.

You should probably use git worktree to have multiple worktrees for the same remote repository instead of multiple clones. You will save much space and I think you should be able to share the stashes.

like image 112
Vampire Avatar answered Nov 15 '22 06:11

Vampire