Source code checkout failure in Bamboo
Asked by Ashish Nigam:

|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                      |
|                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 30-Oct-2023 13:16:21 | Fetching 'refs/heads/bugfix/191.4/SON5-69192-add-new-usm-oss-setting-attach-cells-to-ret-from-oss-data-always-set-to-true' from 'ssh://git@my-bitbucket.abc.com:7999/son5/son5.git'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| 30-Oct-2023 13:16:21 | error: cannot open .git/FETCH_HEAD: Permission denied                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| 30-Oct-2023 13:16:21 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 30-Oct-2023 13:16:21 | Cannot fetch branch 'refs/heads/bugfix/191.4/SON5-69192-add-new-usm-oss-setting-attach-cells-to-ret-from-oss-data-always-set-to-true' from 'ssh://git@my-bitbucket.abc.com:7999/son5/son5.git' to source directory '/home/bamboo/bamboo-agent-home/xml-data/build-dir/_git-repositories-cache/a5325ea61a0162099755c033861f1147d03a4c12'. command \[/usr/bin/git fetch ssh://9744473b-1e25-4ab0-9f08-a9f1ff9b5f05@127.0.0.1:38645/son5/son5.git +refs/heads/bugfix/191.4/SON5-69192-add-new-usm-oss-setting-attach-cells-to-ret-from-oss-data-always-set-to-true:refs/heads/bugfix/191.4/SON5-69192-add-new-usm-oss-setting-attach-cells-to-ret-from-oss-data-always-set-to-true --update-head-ok\] failed with code 255. Working directory was \[/home/bamboo/bamboo-agent-home/xml-data/build-dir/_git-repositories-cache/a5325ea61a0162099755c033861f1147d03a4c12\]., stderr:error: cannot open .git/FETCH_HEAD: Permission denied |


Answers:
author: Shashank Kumar
body: Hello Ashish,

Welcome to Atlassian community.

From the error which you have provided I can see the exception \> "**error: cannot open .git/FETCH_HEAD: Permission denied**"

The Git "Cannot open .git/FETCH_HEAD: Permission denied" error occurs when you try to pull code from a remote repository when the .git/ directory in your server file system is inaccessible to your current user which is running the build.

I am not sure if you are running this on local or remote agent, but if you are running this build on local agent, make sure the user which is running the Bamboo service has read/write access to the above folder. For remote agent you need to provide the similar permission for the user which is running the remote agent.

Regards,

Shashank Kumar

**\*\*please don't forget to Accept the answer if your query was answered\*\***