In both github and gitlab, I can compare two branches or refs in the UI:
https://github.com/*/*/compare/1.x...2.xhttps://*.*.*/*/*/-/compare/1.x...2.xIn github, I can append .diff or .patch to this comparison, to get a raw diff or patch file.
In gitlab, this does not work.
In gitlab, I can append .patch or .diff to a single commit url like ***/-/commit/***.diff, or to a merge request url like ***/-/merge_requests/16.patch`. But it does not work on compare urls.
I like to use these patch urls in package managers like composer, so I don't have to manually create the patch file and save it somewhere.
And sometimes I don't want to apply a single commit or a complete PR/MR, but a very specific range of commits.
How can I get the raw diff or patch file for a comparison in gitlab?
The instance of gitlab I tried this with is https://git.drupalcode.org/. In the help it says the version is 15.11.7-ee.
I think I had the same experience with other gitlab instances.
I'm the maintainer of a Drupal Contrib Module, and was looking for this exact feature, but surprised to find that there is currently (2025) no way to do this via GitLab UI.
The only option is to download a local copy of the module's repository in question and create a diff with the git cli tool.
git clone https://git.drupalcode.org/project/MYMODULE.git
cd MYMODULE
git diff 1.x..2.x > 1.x..2.x.diff
You can add a 👍 on the open feature request to implement this:
https://gitlab.com/gitlab-org/gitlab/-/issues/217206
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