Git merge-base produces no result on build server cloned repo

401 Views Asked by At

I have the following git branch scenario:

     F0---F1---Fn (feature: checked out)
    /
---D0---          (dev)

When I issue the command git merge-base dev HEAD on my local repository it returns the commit SHA for D0.

On our build server, which is a GitLab Runner for GitLab pipelines CI/CD, it clones the repository when a build is triggered. For some reason that I cannot figure out the same command on the server returns nothing.

Any idea what the issue is or what I am missing?

2

There are 2 best solutions below

0
steve dunning On

Increasing the fetch depth was the answer.

0
Mayur Mote On

The issue is with fetch depth. You just need to add the 'GIT_DEPTH' variable to the Gitlab job in which you are executing the git command.

for example,

deploy_release:
  stage: deploy
  variables:
    GIT_DEPTH: 1000 // (Whatever the suitable value for you)
  script: