How to move unpushed commits from a local branch into a separate clone


I have a set of unpushed commits in a local branch… and want to move them into another local branch created out of a new fresh clone. Is that possible?


You need to set the first project as remote branche of the second then get your commits references by using git log and cherry pick merge them to the new branch

cd /home/projectB
git remote add projectA /home/you/projectA
git fetch projectA
git cherry-pick <first_commit>..<last_commit>
git remote remove projectA

Answered By – storm

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published