Cloning a GitHub folder from a repository fails with an error: unable to clone from the given repository

Why do I get an unable to clone from the given repository, please make sure that the remote is available and try again when cloning a git repository

Resolution

UiPath Studio supports cloning a repository and not the folder and subfolders in it. In the below URL, ABC is the owner and Test1 is the repository

https://github.com/ABC/Test1

By using the above URL, UiPath Studio will be able to clone the repository.

Follow the official documentation, which mentions using the repository URL.

Cause: A GitHub repository can have folders and subfolders as shown below.

When you try to clone a folder inside a repository, UiPath Studio throws the below error message

GIT: UiPath.Studio.Contracts.RecoverableException: Unable to clone from the given repository. Please make sure that the remote is available and try again.

—> LibGit2Sharp.LibGit2SharpException: request failed with status code: 404

at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in C:\Work\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 156

at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in C:\Work\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 174

at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) in C:\Work\Git\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 279

at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in C:\Work\Git\libgit2sharp\LibGit2Sharp\Repository.cs:line 793

at UiPath.Studio.Plugin.Git.Desktop.Services.UiAuthenticationSession.Execute[T](ExecuteArgs`1 args)

at UiPath.Studio.Plugin.Git.Services.CloneService.CheckoutCore(String uri, String localFolder, IAuthenticationSession authenticationSession)

— End of inner exception stack trace —

at UiPath.Studio.Plugin.Git.Services.CloneService.CheckoutCore(String uri, String localFolder, IAuthenticationSession authenticationSession)

at System.Threading.Tasks.Task.InnerInvoke()

at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

— End of stack trace from previous location —

at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)

— End of stack trace from previous location —

at UiPath.Studio.Plugin.Git.Services.CloneService.Checkout(String repository, String localFolder, IAuthenticationSession authenticationSession)

at UiPath.Studio.Plugin.Git.Desktop.Services.CheckOutUiService.CheckOut_ExecuteInternal()

at UiPath.Studio.SourceControl.Shared.Desktop.Services.BaseCheckOutUiService`1.CheckOut_Execute()

at UiPath.Studio.SourceControl.Shared.Desktop.Services.BaseCheckOutUiService`1.<get_CheckOutCommand>b__10_0()

at UiPath.Studio.App.Desktop.MVVM.Commands.TaskCommand`3.Execute(TExecuteParameter parameter, Boolean ignoreCanExecuteCheck)

at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)

at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler), HResult -2146233088

Example 1

https://github.com/ABC/Test1/tree/main/Testing

ABC is the owner, and Test1 is the repository. GitHub uses /tree/<branch>/<path> in browser URLs when viewing a directory.

Example 2

https://github.com/ABC/Test1/blob/abc/Testing2/Test

ABC is the owner, and Test1 is the repository. GitHub uses /blob/<branch>/<path> when viewing a single file.

When these example URLs are used for cloning, UiPath Studio throws the error message as shown above.