diff --git a/content/blog/git-merging-within-devops-pipelines.md b/content/blog/git-merging-within-devops-pipelines.md new file mode 100644 index 0000000..30ff171 --- /dev/null +++ b/content/blog/git-merging-within-devops-pipelines.md @@ -0,0 +1,19 @@ +--- +title: "Tip for Git Merge Operations in Azure DevOps Pipelines: Disable Shallow Fetch" +date: 2023-11-28T15:54:49.2610374+08:00 +draft: false +--- + +Azure DevOps pipelines have a self-checkout feature when running a step in a pipeline which automatically runs `git checkout` on the repository you're running against. This generally works fine, however you may experience errors when trying to perform operations such as `git merge` which aren't reproducible locally. + +The errors I experienced were when running `--ff-only` merges + +```fatal: refusing to merge unrelated histories``` + +If you supply `--allow-unrelated-histories`, then `git` errors out with + +```fatal: Not possible to fast-forward, aborting.``` + +To resolve this, I set `fetchDepth` to `0` in the `checkout` step which ensured all commits were fetched and `git` could perform the merge operation. + +The relevant documentation on shallow fetching is available at https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-checkout?view=azure-pipelines#shallow-fetch \ No newline at end of file