Formatted patches
You can apply commits from another branch to the current branch with no problem.
For a single commit, it's a cherry-pick
For a sereis of commit, it's a rebase
However, this needs to be in the same repo. What if you want to apply a commit to a different repo?
How to do it
Well, you can do that via formatted patches. The way it works is that you
save the commit as a formatted patch, a plain text file
send the file to someone
execute the formatted patch
Command
To generate the formatted patch
How it works
Each commit consists of a set of changes, and each change can be expressed as an instruction. A formatted patch is a text version of these instructions, which Git can understand and run.
What to look out for
To apply the formatted patch, the current file should be compatible. For example, if the change is to remove the line import pandas as pd
in file analyse.py
, it will fail if
you don't have a file named
analyse.py
, orthe file doens't have this line
Last updated