Cloning a specific tag, might return 'detached HEAD' state.
As a workaround, try to clone the repo first, and then checkout a specific tag. For example:
repo_url=https://github.com/owner/project.git
repo_dir=$(basename $repo_url .git)
repo_tag=0.5
git clone --single-branch $repo_url # using --depth 1 can show no tags
git --work-tree=$repo_dir --git-dir=$repo_dir/.git checkout tags/$repo_tag
Note: Since Git 1.8.5, you can use -C <path>
, instead of --work-tree
and --git-dir
.