Unable to clone a repository with specific tag and depth 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
Unable to clone repository with specific tag and depth on Windows using the following command:
1
git clone --branch <branch-name> --depth 1 <repository clone URL>
Environment
Operating System: Windows
Diagnosis
This issue is seen mostly with Windows machines. The first troubleshooting step to resolve issues like these should be to check the Git versions in use. If that doesn't help then do further diagnosis of the issue. Check the version of Git client, Git server and Git LFS.
Check the following:
The version of Bitbucket and supported platforms page for compatibility with Git. If the Git versions are same as what is listed in the supported platforms page the issue persists, then update them to the latest available Git versions.
If there's proxy in place
If the clone command works without the
tag
anddepth
optionIf the issue occurs with both HTTP and SSH url
If the issue is specific to a few users and system only.
Check for errors in Git debug logs and Bitbucket logs.
You would see the following logs from the Git trace:
1
2
3
4
5
6
7
11:45:23.297062 git.c:419 trace: built-in: git clone --branch <branch-name> --depth 1 <repository clone URL>
fatal: destination path '<repository>' already exists and is not an empty directory.
Checking out files: 100% (17613/17613), done.
Filtering content: 99% (613/619), 394.34 MiB | 118.64 MiB/s
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD
Run the
git status
command and retry the checkout withgit checkout -f HEAD.
Run the above command while running Process Monitor.
Process Monitor can be downloaded from Process Monitor - Windows Sysinternals - Microsoft Docs. It doesn't require installation, just extracting the zip is enough.
Run the .exe
The tool will start capturing events automatically
Run
git checkout -f HEAD
, wait for it to failOnce it's failed, return to Process Monitor, press CTRL+E to stop capturing events
Save the file from Process Monitor as PML file
After the failed checkout following the clone, if running git checkout -F HEAD works fine and all the expected data is there, so the question is why the checkout as part of the clone fails.
As the issue is reported with git clone --branch <branch-name> --depth 1 <https repository clone URL>, narrow it down by answering following questions -
Is it failing because of --depth? For this, check output of following commands -
1 2
git clone --branch <branch> <https repository clone URL> git clone --branch <branch> --single-branch <https repository clone URL>
Does the error happen because of server or it's happening locally. For this, try the following commands -
1 2 3
git clone <https repository clone URL> cd <repository folder> git checkout <branch>
Is LFS of
.dll
files the reason for failure? For this, perform following steps -
Clone the repo.
Checkout a new branch named
<some-test-branch>
Remove all DLL files in this branch and make a local commit.
Push this new branch to upstream.
cd
into separate directory and rungit clone --branch
<some-test-branch>
--depth 1 <https repository clone URL>
and see if it passes.
Errors from the Bitbucket server side for this repository:
1
c.a.s.i.w.filters.StreamGuardFilter The remote client has aborted the connection
Cause
In most cases the cause of the issue is incorrect version of Git and Git LFS in use.
Solution
Upgrade the Git client and server version to the latest available version.
Upgrade the Git LFS version to the latest available version.
Was this helpful?