As I am working on some open source projects with the community, it is best to send file patches instead of merge requests. A couple of projects are not using GitHub or GitLab, and the team leader needs us to send the patch file instead of pushing directly to the main git repository — for testing and staging purposes.
Fortunately git can export those commits into patches with this command:
git format-patch -x
Where -x means how many commits back from the current head, and it has to be an integer.
For example, if I want to generate patches for the 10 last commits:
git format-patch -10
The above example will generate 10 file patches. This can cause a problem for the team leader because they need to apply the patches one by one. You can squash those patches into 1 single file patch. See the command below:
git format-patch -x --stdout > patch-ddmmyyy.patch
From the format above, all those generated patches will be combined into 1 output file. As a standard, I usually add the date to the filename so I know when I generated it.
Note: The generated patches also work with Subversion (SVN).
That’s all — any questions, please let me know.
