Creating a delta artifact by using git diff between two commits in a single branch

Greetings ! I am trying to create a delta artifact by using git diff between two commits in a single branch.
Running the git diff in a powershell task which i have tested and found to be working in local.

The same command wasnt working through the pipeline using a Microsoft hosted agent and I found the reason to be the checkout of the branch. It does not have the commit history … Only gets the latest i believe. When i do a git list or rev-list … and count it returns zero.

Running git fetch -all is throwing some errors . What am i missing. Please help ?

https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-checkout?view=azure-pipelines#shallow-fetch

Thank you … also found something else …

https://dev.to/kkazala/azure-devops-pipelines-shallow-fetch-1-is-now-default-4656 … the issue … shallow fetch … default depth is set to 1 in azure

and this is the recommended solution for yaml pipelines …

  - checkout: self
    fetchDepth: 2/3/..or...5...n```
trying this out now . .. they made this change and did not even document it ...

Your link recommends the same. thank you !

Yes I linked to the official docs that contain a warning about this change