Hi,
I have been using Sourcetree (3.4.8) to pull from Bitbucket data center for a long time, but recently have had issues with it and it is no longer working.
No recent updates, but a little while ago Sourcetree wouldn't open (the blue logo came up but nothing happened). A reinstall fixed the issue, but after reconfiguring, Sourcetree stopped being able to pull anything and threw the error:
“git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --no-tags origin
error: cannot open '.git/FETCH_HEAD': Permission denied
error: cannot open '.git/FETCH_HEAD': Permission denied
error: cannot open '.git/FETCH_HEAD': Permission denied
error: cannot open '.git/FETCH_HEAD': Permission denied
Completed with errors, see above.”
I am able to successfully pull from the same repo in a Git Bash terminal (same SSH key as well), so I am not sure what's going on.
I have had a look at the logs, but it is not obvious where this error occurs.
Any help is much appreciated, even just on where to look for more info.
Because Git Bash can pull successfully but Sourcetree cannot, this is unlikely to be an SSH key or Bitbucket problem. The error specifically indicates that Sourcetree cannot write to the local repository's .git/FETCH_HEAD file. [stackoverflow.com], [community....assian.com]
A few things I'd check:
.gitNavigate to the repository and inspect:
and the entire .git folder.
Make sure your Windows user account has Modify or Full Control permissions. Several reports of this error were ultimately caused by Windows permissions on the repository or .git directory. [stackoverflow.com], [stackoverflow.com]
FETCH_HEAD is locked by another processSince Git Bash works and Sourcetree doesn't, it's possible another process is holding the file open for Sourcetree's Git process.
Try:
(or delete it from Explorer)
FETCH_HEAD is recreated automatically on the next fetch. [golinuxcloud.com], [codemia.io]
Also check for:
and remove it if present while Git is closed.
After reinstalling, Sourcetree may have switched from System Git to its Embedded Git.
In:
check whether it's using:
Since Git Bash works, try setting Sourcetree to the same System Git installation used by Git Bash.
Not necessarily as a permanent fix, but as a diagnostic test.
If the fetch succeeds when run elevated, that strongly suggests a Windows permissions/ownership problem with the repository folder. [stackoverflow.com]
If the repo is under a protected folder such as:
or a synced folder with special permissions (OneDrive, network share, etc.), try cloning the repository into a simple location such as:
and test there. Permission-related FETCH_HEAD issues are commonly tied to repository ownership or location. [stackoverflow.com], [golinuxcloud.com]
Given your timeline:
cannot open '.git/FETCH_HEAD': Permission denied.My first suspicion would be that the reinstall changed Sourcetree's Git configuration (Embedded vs System Git) or Sourcetree is running under a different permission context than before.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.