If you want to move a complete commit from one repository to another (and you don’t want to add it as a remote), you can use these steps:
Create a patch
In the source repository, create a patch based on the commit by running
git format-patch SHA1_OF_COMMIT~..SHA1_OF_COMMIT
Example –
git format-patch c2d42a0583481652ce037b899beef45d9858b98f~..c2d42a0583481652ce037b899beef45d9858b98f
(note the ~
).
This will create a .patch
file that describes this commit.
Apply the patch
In the target repository, apply the patch with
git apply PATH_TO_PATCH
Example –
git apply Documents\backend\0001-Add-userBlock-middleware-admin-features.patch
If the patch does not apply cleanly, git will not do anything. If you want it to apply as much as possible, use
git apply PATH_TO_PATCH --reject
The parts that could not be applied cleanly end up in .rej
files. Take care of those manually.
No Comments
Leave a comment Cancel