Hi,
Hopefully someone can help - I’m trying to build out a CD pipeline using Drone and have a final issue to resolve.
Can anyone tell me why, when the trigger event is a tag hook, the local Git repo is in a detached state eg
git branch
results in
* (HEAD detached at FETCH_HEAD)
This is a problem as I cant get the branch name (by using git branch), this is what we want to put into the tag that the image gets published with. I have tried checking out the commit associated with the tag but the same thing happens.
Any help greatly appreciated
When drone clones a tag it reflects the fact that a git tag has no direct relationship to a git branch. There is a stackoverflow question [1] that explains this in greater detail that might be useful.
A tag is a pointer to a commit, and commits exist independently of branches. It is important to understand that tags have no direct relationship with branches - they only ever identify a commit. That commit can be pointed to from any number of branches - i.e., it can be part of the history of any number of branches - including none. Therefore, running git show to see a tag’s details contains no reference to any branches, only the ID of the commit that the tag points to.
[1] https://stackoverflow.com/questions/14613540/do-git-tags-only-apply-to-the-current-branch#27154277