Long term, what you want is to use git worktrees.
In order to repair your current situation, you can cherry-pick between repos by creating remotes from your local directories.
By adding another local repo as a remote and doing a git fetch
, you can cherry-pick any commit you want from that repo with just the SHA.
For example, if you want to cherry-pick the commit from old_clone
with a SHA starting with e9bee1bc
:
cd /projects/new_clone
git remote add old_clone /projects/old_clone
git fetch old_clone
git cherry-pick e9bee1bc
You could also use a similar strategy to convert your multiple cloned remotes into worktrees. For example, if you want to create a worktree from your original project and add a local copy of branch1
from new_clone
to your new worktree:
cd /projects/original
git worktree add /projects/worktree_1
cd /projects/worktree_1
git remote add new_clone /projects/new_clone
git fetch new_clone
git switch -c branch1 new_clone/branch1