likeachamp likeachamp -4 years ago 118
Git Question

How do I move local, unpushed, commits from a corrupt git repository to another repository?

Normally I can move pushed commits to another repository using

cherry-pick
: I
fetch
the related branch from 'another' repository to my new repo and
cherry-pick
with commit's ID.

I want to do the same thing for local--unpushed--commits in a corrupt repository (something went wrong and I cannot push my changes, but I need to move them to another repo).

Is there any way to
cherry-pick
commits from the corrupt repo to another repo?

PS: Both repositories exist on the same machine.

Answer Source

Another possible method.

cd repo1_path
git format-patch -1 <commit> --stdout > /tmp/xxx.patch
cd repo2_path
git checkout <branch>
git am /tmp/xxx.patch
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download