Skip to content

LibGit2Sharp.NameConflictException: failed to write reference 'refs/heads/feature/gitymltest': a reference with that name already exists. #3690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Softhies opened this issue Sep 14, 2023 · 2 comments
Labels

Comments

@Softhies
Copy link

Softhies commented Sep 14, 2023

Describe the bug
exceptions success when running a on azure devop build step gitversion/execute:

LibGit2Sharp.NameConflictException: failed to write reference 'refs/heads/feature/gitymltest': a reference with that name already exists.

Unfortunately, it does not occur locally and powershell on buildserver agentserver but on the Azure DevOps build server/ pipeline.

i am lost, is there a solution?

my GitVersion.yml

mode: ContinuousDeployment
continuous-delivery-fallback-tag:
branches: {}
ignore:
  sha: []
  commits-before: 2020-01-01T01:01:00
increment: Inherit
merge-message-formats: {}
update-build-number: true

pipline steps:

  - task: gitversion/setup@0
    displayName: gitversion/setup
    inputs:
      versionSpec: 5.*
      includePrerelease: true
  - task: gitversion/execute@0
    displayName: gitversion/execute
    inputs:
      useConfigFile: true
      configFilePath: GitVersion.yml
      updateAssemblyInfo: true
      updateAssemblyInfoFilename: $(Build.SourcesDirectory)\Keasy.Win\Properties\AssemblyInfo.cs

command:

C:\AGENT\_work\_tool\GitVersion.Tool\5.12.0\x64\dotnet-gitversion.exe C:/AGENT/_work/19/s /output json /output buildserver /updateassemblyinfo C:\AGENT\_work\19\s\Project.Win\Properties\AssemblyInfo.cs

exception log:

2023-09-14T10:17:57.3342771Z [command]C:\AGENT\_work\_tool\GitVersion.Tool\5.12.0\x64\dotnet-gitversion.exe C:/AGENT/_work/19/s /output json /output buildserver /updateassemblyinfo C:\AGENT\_work\19\s\Keasy.Win\Properties\AssemblyInfo.cs
2023-09-14T10:18:00.1391348Z INFO [09/14/23 12:17:58:06] Working directory: C:/AGENT/_work/19/s
2023-09-14T10:18:00.1393734Z INFO [09/14/23 12:17:58:14] Project root is: C:\AGENT\_work\19\s\
2023-09-14T10:18:00.1395610Z INFO [09/14/23 12:17:58:14] DotGit directory is: C:\AGENT\_work\19\s\.git
2023-09-14T10:18:00.1397514Z INFO [09/14/23 12:17:58:14] Branch from build environment: refs/heads/feature/gitymltest
2023-09-14T10:18:00.1399568Z INFO [09/14/23 12:17:58:14] Begin: Normalizing git directory for branch 'refs/heads/feature/gitymltest'
2023-09-14T10:18:00.1401821Z   INFO [09/14/23 12:17:58:26] One remote found (origin -> '').
2023-09-14T10:18:00.1404339Z   INFO [09/14/23 12:17:58:26] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2023-09-14T10:18:00.1406643Z   INFO [09/14/23 12:17:58:77] Creating local branch feature/gitymltest
2023-09-14T10:18:00.1408612Z   INFO [09/14/23 12:17:58:81] End: Normalizing git directory for branch 'refs/heads/feature/gitymltest' (Took: 667.42ms)
2023-09-14T10:18:00.1410747Z   INFO [09/14/23 12:17:58:88] Attempting to show the current git graph (please include in issue): 
2023-09-14T10:18:00.1412447Z   INFO [09/14/23 12:17:58:88] Showing max of 100 commits
2023-09-14T10:18:00.1414202Z   INFO [09/14/23 12:18:00:06] * 30d39aaa 2 minutes ago  (HEAD, origin/Feature/gitymltest)
2023-09-14T10:18:00.1415697Z * 5ff778d3 23 minutes ago 
2023-09-14T10:18:00.1416653Z * 95ffec8b 26 minutes ago 
2023-09-14T10:18:00.1417581Z * 71e320d0 28 minutes ago 
...
2023-09-14T10:18:00.1453769Z   ERROR [09/14/23 12:17:58:88] An unexpected error occurred:
2023-09-14T10:18:00.1455525Z LibGit2Sharp.NameConflictException: failed to write reference 'refs/heads/feature/gitymltest': a reference with that name already exists.
2023-09-14T10:18:00.1457550Z    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
2023-09-14T10:18:00.1459335Z    at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
2023-09-14T10:18:00.1461696Z    at LibGit2Sharp.Core.Proxy.git_reference_create(RepositoryHandle repo, String name, ObjectId targetId, Boolean allowOverwrite, String logMessage) in /_/LibGit2Sharp/Core/Proxy.cs:line 1889
2023-09-14T10:18:00.1464469Z    at LibGit2Sharp.ReferenceCollection.Add(String name, ObjectId targetId, String logMessage, Boolean allowOverwrite) in /_/LibGit2Sharp/ReferenceCollection.cs:line 194
2023-09-14T10:18:00.1467253Z    at LibGit2Sharp.ReferenceCollection.Add(String name, String canonicalRefNameOrObjectish, String logMessage, Boolean allowOverwrite) in /_/LibGit2Sharp/ReferenceCollection.cs:line 143
2023-09-14T10:18:00.1469992Z    at LibGit2Sharp.ReferenceCollection.Add(String name, String canonicalRefNameOrObjectish, Boolean allowOverwrite) in /_/LibGit2Sharp/ReferenceCollection.cs:line 167
2023-09-14T10:18:00.1472963Z    at GitVersion.ReferenceCollection.Add(String name, String canonicalRefNameOrObject, Boolean allowOverwrite) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\ReferenceCollection.cs:line 14
2023-09-14T10:18:00.1476026Z    at GitVersion.GitPreparer.EnsureLocalBranchExistsForCurrentBranch(IRemote remote, String currentBranch) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 391
2023-09-14T10:18:00.1480466Z    at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 164
2023-09-14T10:18:00.1483475Z    at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
2023-09-14T10:18:00.1486266Z    at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
2023-09-14T10:18:00.1488633Z    at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
2023-09-14T10:18:00.1491032Z    at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
2023-09-14T10:18:00.1494259Z    at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
...
2023-09-14T10:18:00.1592597Z 
2023-09-14T10:18:00.1593634Z INFO [09/14/23 12:17:57:89] Applicable build agent found: 'AzurePipelines'.
2023-09-14T10:18:00.1595095Z INFO [09/14/23 12:17:58:06] Working directory: C:/AGENT/_work/19/s
2023-09-14T10:18:00.1596422Z INFO [09/14/23 12:17:58:14] Project root is: C:\AGENT\_work\19\s\
2023-09-14T10:18:00.1597809Z INFO [09/14/23 12:17:58:14] DotGit directory is: C:\AGENT\_work\19\s\.git
2023-09-14T10:18:00.1599313Z INFO [09/14/23 12:17:58:14] Branch from build environment: refs/heads/feature/gitymltest
2023-09-14T10:18:00.1601031Z INFO [09/14/23 12:17:58:14] Begin: Normalizing git directory for branch 'refs/heads/feature/gitymltest'
2023-09-14T10:18:00.1602854Z   INFO [09/14/23 12:17:58:26] One remote found (origin -> '').
2023-09-14T10:18:00.1605001Z   INFO [09/14/23 12:17:58:26] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2023-09-14T10:18:00.1606963Z   INFO [09/14/23 12:17:58:77] Creating local branch feature/gitymltest
2023-09-14T10:18:00.1609095Z   INFO [09/14/23 12:17:58:81] End: Normalizing git directory for branch 'refs/heads/feature/gitymltest' (Took: 667.42ms)
2023-09-14T10:18:00.1610777Z   ERROR [09/14/23 12:17:58:88] An unexpected error occurred:
2023-09-14T10:18:00.1612511Z LibGit2Sharp.NameConflictException: failed to write reference 'refs/heads/feature/gitymltest': a reference with that name already exists.
2023-09-14T10:18:00.1614537Z    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
2023-09-14T10:18:00.1616298Z    at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
2023-09-14T10:18:00.1619040Z    at LibGit2Sharp.Core.Proxy.git_reference_create(RepositoryHandle repo, String name, ObjectId targetId, Boolean allowOverwrite, String logMessage) in /_/LibGit2Sharp/Core/Proxy.cs:line 1889
2023-09-14T10:18:00.1621799Z    at LibGit2Sharp.ReferenceCollection.Add(String name, ObjectId targetId, String logMessage, Boolean allowOverwrite) in /_/LibGit2Sharp/ReferenceCollection.cs:line 194
2023-09-14T10:18:00.1624596Z    at LibGit2Sharp.ReferenceCollection.Add(String name, String canonicalRefNameOrObjectish, String logMessage, Boolean allowOverwrite) in /_/LibGit2Sharp/ReferenceCollection.cs:line 143
2023-09-14T10:18:00.1627340Z    at LibGit2Sharp.ReferenceCollection.Add(String name, String canonicalRefNameOrObjectish, Boolean allowOverwrite) in /_/LibGit2Sharp/ReferenceCollection.cs:line 167
2023-09-14T10:18:00.1630298Z    at GitVersion.ReferenceCollection.Add(String name, String canonicalRefNameOrObject, Boolean allowOverwrite) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\ReferenceCollection.cs:line 14
2023-09-14T10:18:00.1634383Z    at GitVersion.GitPreparer.EnsureLocalBranchExistsForCurrentBranch(IRemote remote, String currentBranch) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 391
2023-09-14T10:18:00.1637515Z    at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 164
2023-09-14T10:18:00.1640548Z    at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
2023-09-14T10:18:00.1643329Z    at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
2023-09-14T10:18:00.1645673Z    at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
2023-09-14T10:18:00.1648089Z    at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
2023-09-14T10:18:00.1650796Z    at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
2023-09-14T10:18:00.1653062Z   INFO [09/14/23 12:17:58:88] Attempting to show the current git graph (please include in issue): 
2023-09-14T10:18:00.1654494Z   INFO [09/14/23 12:17:58:88] Showing max of 100 commits
2023-09-14T10:18:00.1655918Z   INFO [09/14/23 12:18:00:06] * 30d39aaa 2 minutes ago  (HEAD, origin/Feature/gitymltest)
2023-09-14T10:18:00.1657135Z * 5ff778d3 23 minutes ago 
2023-09-14T10:18:00.1657992Z * 95ffec8b 26 minutes ago 
2023-09-14T10:18:00.1658874Z * 71e320d0 28 minutes ago 
2023-09-14T10:18:00.1659718Z * 8b83d7ec 36 minutes ago 
2023-09-14T10:18:00.1660618Z *   ff3f47f1 42 minutes ago 
2023-09-14T10:18:00.1661331Z |\  
2023-09-14T10:18:00.1662171Z | * d3e5e78f 45 minutes ago  (Feature/gitymltest)
2023-09-14T10:18:00.1663190Z * | 9a595d75 43 minutes ago 
2023-09-14T10:18:00.1663894Z |/  
2023-09-14T10:18:00.1664624Z * 000f062d 61 minutes ago 
2023-09-14T10:18:00.1665473Z * 55ea7763 89 minutes ago 
2023-09-14T10:18:00.1666770Z * 1288032c 2 hours ago 
2023-09-14T10:18:00.1667634Z * ad4e58e4 3 hours ago 
2023-09-14T10:18:00.1668566Z | * 3b4a695b 24 minutes ago  (origin/develop)
...
2023-09-14T10:18:00.1785062Z 
2023-09-14T10:18:00.1785991Z   INFO [09/14/23 12:18:00:10] Done writing 
2023-09-14T10:18:00.1868843Z ##[error]TypeError: Cannot read property 'message' of undefined
2023-09-14T10:18:00.1913537Z ##[section]Abschließen: gitversion/execute
@Softhies Softhies added the bug label Sep 14, 2023
@asbjornu
Copy link
Member

Please have a look through #864 and #2593 which seems to be duplicates of this.

@HHobeck
Copy link
Contributor

HHobeck commented Dec 8, 2023

Please check the preview version of git version (currently it is the 6.0.0-beta.3 version) and check whether the problem is solved or not.

Thank you very much.

@HHobeck HHobeck closed this as completed Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants