(I can see there are many questions about this but I haven't found one that solves my exact problem).
I'm running gitlab-ci and when the runner checks out my code it does so as a detached head. Here is what I get when running a git status
command in the runners directory.
git status
# HEAD detached at 847fe59
nothing to commit, working directory clean
What I need to do for what I am working on is to re-attach this head back to my develop branch and then git pull
in the full repo for use in a docker container. I guess gitlab ci only checks out the last commit to save cloning down the full repo which is understandable.
In my .gitlab-ci.yml
file I've tried the following...
- git checkout origin/$CI_BUILD_REF_NAME
- git pull
Which gives the following output in the console...
$ git checkout $CI_BUILD_REF_NAME
Switched to a new branch 'develop'
Branch develop set up to track remote branch develop from origin.
$ git pull
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.
Is there an easy way to reattach the head? Most of the solutions I've seen deal with the fact a change has been committed onto the detached head however this isn't the case for me. I just want to get my full develop
branch in my docker container with all of my git history.
Or if there is a way to stop gitlab ci from checking out the detached head that would also be great.