diff --git a/src/ThisAssembly.Git/ThisAssembly.Git.targets b/src/ThisAssembly.Git/ThisAssembly.Git.targets
index 41e34f44..78e25666 100644
--- a/src/ThisAssembly.Git/ThisAssembly.Git.targets
+++ b/src/ThisAssembly.Git/ThisAssembly.Git.targets
@@ -86,7 +86,10 @@
<_ThisAssemblyGitHead Condition="'$(_ThisAssemblyGitHead)' == '' and '$(_ThisAssemblyGitDir)' != '' and Exists('$(_ThisAssemblyGitDir)/HEAD')">$(_ThisAssemblyGitDir)/HEAD
<_ThisAssemblyGitBranchName Condition="'$(_ThisAssemblyGitBranchName)' == '' and '$(_ThisAssemblyGitHead)' != ''">$([System.IO.File]::ReadAllText('$(_ThisAssemblyGitHead)').Trim())
- $(_ThisAssemblyGitBranchName.TrimStart("ref:").Trim().Replace('refs/heads/', '').Replace('refs/tags/', ''))
+
+ <_ThisAssemblyGitBranchName Condition="'$(_ThisAssemblyGitBranchName)' != '' and $(_ThisAssemblyGitBranchName.StartsWith('ref: '))">$(_ThisAssemblyGitBranchName.Substring(5))
+ $(_ThisAssemblyGitBranchName.Trim().Replace('refs/heads/', '').Replace('refs/tags/', ''))