Jump to: navigation, search

Move a commit to another repo

If you have a commit in one repo that you want to move into another repo here are some easyISH steps to move it. (I stole learned this from http://factore.ca/on-the-floor/51-applying-merging-changes-from-one-git-repository-to-another)

Create a new folder just outside your repo and clone the other repo to it.

From that new repo run git log

deving@server2:~/public_laravel4 (master)$ git log
commit 01e32b7c6e2b2333d24ffb24ed2581da9394918f
Author: RiDdLeS <riddles@dev-toolbox.com>
Date:   Thu Oct 17 17:38:01 2013 -0500

    Fixing the width of the text area in the compose modal from stygianvault

commit e1d6cc20381c80f6dc216f0f538f9c4aca242851
Author: RiDdLeS <riddles@dev-toolbox.com>
Date:   Thu Oct 17 17:34:06 2013 -0500

    Dont allow message to be sent to yourself TRAVIS

commit d8c8891ac6e15f1e8d83eab4dfd62cc367e18fc0
Author: RiDdLeS <riddles@dev-toolbox.com>
Date:   Thu Oct 17 16:58:42 2013 -0500

    Fixing the UserControllers ability to edit themes from stygianvault

commit 06ee42b3ba5145a35678177941b40191374e2325
Author: RiDdLeS <riddles@dev-toolbox.com>
Date:   Thu Oct 17 16:55:37 2013 -0500

    Fixing admin review flag when the report is removed from stygianvault

Lets say i want a patch for the last to commits. I would grab the md5 commit hash just below the commit it want which is "d8c8891ac6e15f1e8d83eab4dfd62cc367e18fc0"

Next run: git format-patch d8c8891ac6e15f1e8d83eab4dfd62cc367e18fc0

This will generate two files.

Move these files to your other repo.

Once your in your other repo run: git apply --check <filename>

This will make sure there are no errors when the patch is applied. No ouput is good.

Then run git apply <filename>

Commit your changes and your all done.

If you get patch does not apply on a file then ether figure out what change and adjust the patch or just edit the patch and remove the change and do it by hand.