Git operations failing due to corrupted git cache on Windows

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Git cache corruptions can cause errors on builds and tasks in Bamboo. The git cache Bamboo keeps on the disk consists of the .git content of the repository (the reference tree) which is persisted in several small files that get created/modified/removed when a cache refresh is performed. Sometimes this cache might get corrupted if antivirus scans or continuous monitoring temporarily locks one or more files while a git cache update is in progress.

Environment

Bamboo running on Windows with antivirus software scanning Bamboo's home directory.

Diagnosis

The following errors can be seen in Bamboo builds & logs:

RSS detection – Fatal: Not a git repository (or any of the parent directories)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2021-11-21 07:54:50,613 INFO [17-BAM::SpecsDetection:pool-25-thread-4] [RssDetectionRunnable] Exception while executing RSS detection for RssDetectionWork[repository=209190915,branch=dev] com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.plugins.git.GitCommandException: command ['C:\Program Files\Git\bin\git.exe' fetch --no-tags ssh://f2e32a9a-38df-476d-b48e-3b2be1aa9560@127.0.0.1:55590/XXXXXXX/XXXXXXXXXX.git +refs/heads/dev:refs/heads/dev --update-head-ok] failed with code 128. Working directory was [D:\ProgramFiles\bb\xml-data\build-dir\_git-repositories-cache\b65e73d2eaa5af192ac051c156369130f6fba63a]., stderr: fatal: Not a git repository (or any of the parent directories): .git at com.atlassian.bamboo.plugins.stash.v2.BitbucketServerBambooSpecsHandler.detectSpecRevision(BitbucketServerBambooSpecsHandler.java:24) at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.getRssDetectionTriggerData(RssDetectionServiceImpl.java:324) at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.runRssDetection(RssDetectionServiceImpl.java:357) at com.atlassian.bamboo.configuration.external.detection.RssDetectionRunnable.run(RssDetectionRunnable.java:42) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) at java.lang.Thread.run(Thread.java:745) Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command ['C:\Program Files\Git\bin\git.exe' fetch --no-tags ssh://f2e32a9a-38df-476d-b48e-3b2be1aa9560@127.0.0.1:55590/ltk/bamboo-plans.git +refs/heads/dev:refs/heads/dev --update-head-ok] failed with code 128. Working directory was [D:\ProgramFiles\bb\xml-data\build-dir\_git-repositories-cache\b65e73d2eaa5af192ac051c156369130f6fba63a]., stderr: fatal: Not a git repository (or any of the parent directories): .git at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:746) at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runFetchCommand(GitCommandProcessor.java:317) at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.obtainLatestRevision(NativeGitOperationHelper.java:649) at com.atlassian.bamboo.plugins.git.v2.GitBambooSpecsHandler.lambda$detectSpecRevision$3(GitBambooSpecsHandler.java:66)

Fatal: Not a git repository (or any of the parent directories)

1 (com.atlassian.bamboo.repository.RepositoryException : com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: : Cannot fetch branch 'refs/heads/feature/XXXXXXXXXX' from 'ssh://git@bitbucket-prod.XXXXXXXX:7999/XXXXXX/XXXXXX.git' to source directory 'D:\ProgramFiles\bb\xml-data\build-dir_git-repositories-cache\a22e07f8134f869882dead006f1a24456dc01d81'. command ['C:\Program Files\Git\bin\git.exe' fetch ssh://940fea21-7882-4bb2-83bf-2616ce7a2982@127.0.0.1:55590/XXXXX/XXXXXXX.git +refs/heads/feature/XXXXXXXXXXXXX:refs/heads/feature/XXXXXXXXXXXXXXXX --update-head-ok] failed with code 128. Working directory was [D:\ProgramFiles\bb\xml-data\build-dir_git-repositories-cache\a22e07f8134f869882dead006f1a24456dc01d81]., stderr: fatal: Not a git repository (or any of the parent directories): .git)

Failed to extract changesets, will return a stub changeset

1 2 3 4 5 6 2022-04-18 14:27:16,772 ERROR [10-BAM::PlanExec:pool-17-thread-1] [GitChangeDetector] : Failed to extract changesets, will return a stub changeset. com.atlassian.bamboo.repository.RepositoryException: : Cannot fetch branch 'refs/heads/master' from 'ssh://git@bitbucket.org/.../...' to source directory 'F:\Program Files\Atlassian\bamboo-home\local-working-dir\_git-repositories-cache\012118bbbe64222300cceefcf8a5bc8096810987'. command ['C:\Program Files\Git\cmd\git.exe' fetch --no-tags ssh://ac537273-1a1f-4201-b32a-8c7edfaab1a9@127.0.0.1:50530/.../... +refs/heads/master:refs/heads/master --update-head-ok] failed with code 128. Working directory was [F:\Program Files\Atlassian\bamboo-home\local-working-dir\_git-repositories-cache\012118bbbe64222300cceefcf8a5bc8096810987]., stderr: fatal: not a git repository (or any of the parent directories): .git [...] Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command ['C:\Program Files\Git\cmd\git.exe' fetch --no-tags ssh://ac537273-1a1f-4201-b32a-8c7edfaab1a9@127.0.0.1:50530/.../... +refs/heads/master:refs/heads/master --update-head-ok] failed with code 128. Working directory was [F:\Program Files\Atlassian\bamboo-home\local-working-dir\_git-repositories-cache\012118bbbe64222300cceefcf8a5bc8096810987]., stderr: fatal: not a git repository (or any of the parent directories): .git

Cause

Antivirus may lock some of the files while scanning them and prevent Bamboo from updating/refreshing the cache.

Other possibilities: hardware failure, OS failures, network or Git client errors.

Solution

Antivirus

Disable the continuous monitoring and scans for the Bamboo directories.

Manual cache cleanup

You may also need to remove the cache from the agents, if enabled. It's located under<AGENT_HOME>/xml-data/build-dir/_git-repositories-cache/.

Updated on March 20, 2025

Still need help?

The Atlassian Community is here for you.