1. git

git – move a commit between repositories

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.

https://arshohag.rdevs.xyz
Do you like Ashiqur Rahman's articles? Follow on social!
Comments to: git – move a commit between repositories

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

Login

Welcome to rDevs

Brief and amiable onboarding is the first thing a new user sees in the theme.
Join rDevs

start writing