For example, let's say I have two files, A and B. I created B as a copy of A but I want them to be very similar - I only want a couple lines different in B. Is there a way in Git to sync these changes in any way, or a more efficient way to accomplish this task?
You have the following options:
Use apply-patch-to-file. Where you can generate the patch using:
git format-patch HEAD^
And then apply using:
apply-patch-to-file -i ~/patches/0001-my-test-commit.patch
You will be prompted and asked on what files the patch should be applied.
Use directly the patch
command, by creating the diff like:
git diff HEAD^ -- hello.test > ~/patch_file
Then apply the diff to a different file:
patch -p1 another_path/subdir/different_file.test ~/patch_file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With