Sourcetree Crashes when Cloning a Repository
Asked by Jason Harrington:

I have been using Sourcetree with two Gitlab repositories for several months without any issues. Recently, I wanted to add a third repository and every time I try to clone the new repository to Sourcetree, it crashes (Sourcetree locks up and I have to use the Task Manager to close it) When I paste the HTTPS address from GitLab, Sourcetree recognizes the repository as a Git repository. A status circle starts spinning next to Advanced options and then Sourcetree freezes up.

The version of Sourcetree that I have installed is 3.4.5. Within the windows event viewer, I have noticed two errors that pop up. My colleague has been able to close the repository on his computer using Sourcetree without any issues. Do you have any ideas why this is happening?

Thanks,

Jason Harrington


Answers:
author: Miro XY
body: Hi,

I had the same error.

I solved it as follows:

- uninstall version 3.4.5

- delete folder c:\\Users\\USERNAME\\AppData\\Local\\Atlassian

- instal version 3.4.4 <https://product-downloads.atlassian.com/software/sourcetree/windows/ga/SourceTreeSetup-3.4.4.exe>

Miro

comments: author: Jason Harrington
body: Miro,

Thank you so much! That fixed my problem.

-Jason


author: Pavariss Lintha
body: Thank you , fixed my problem.


author: Wojtek Tomalik
body: if you don't want to revert to an older version of the software, see Aidan's answer below - making sure the repo is not empty worked for me as well.


author: Jay Ben
body: Niubi ?


author: a2cworks
body: Still happens in version 3.4.7. ?  
The bug is not fixed yet. (?????)


author: Sagar Srivastava
body: I confirm. its still crashing at this step in 3.4.7 and 3.4.4 works


author: MOHAMOD Shah
body: Having the same issue with version 3.4.7. Found the following error information in Windows Event Viewer:

Application: SourceTree.exe  
Framework Version: v4.0.30319  
Description: The process was terminated due to an unhandled exception.  
Exception Info: System.IndexOutOfRangeException  
at SourceTree.Repo.RepoHandlerGitOld.GetDefaultBranch(System.String)  
at SourceTree.ViewModel.CloneNewDialogViewModel+\<\>c__DisplayClass212_0.\<RefreshRemoteBranches\>b__1()  
at System.Threading.Tasks.Task\`1\[\[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\]\].InnerInvoke()  
at System.Threading.Tasks.Task.Execute()  
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()  
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)  
at System.Runtime.CompilerServices.TaskAwaiter\`1\[\[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\]\].GetResult()  
at SourceTree.ViewModel.CloneNewDialogViewModel+\<RefreshRemoteBranches\>d__212.MoveNext()  
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()  
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)  
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()  
at SourceTree.ViewModel.CloneNewDialogViewModel+\<CheckSource\>d__211.MoveNext()

Exception Info: ReactiveUI.UnhandledErrorException  
at ReactiveUI.RxApp+\<\>c__DisplayClass11_0.\<.cctor\>b__2()  
at System.Reactive.Concurrency.Scheduler.Invoke(System.Reactive.Concurrency.IScheduler, System.Action)  
at System.Reactive.Concurrency.DispatcherScheduler+\<\>c__DisplayClass12_0\`1\[\[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\]\].\<Schedule\>b__0()  
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)  
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)  
at System.Windows.Threading.DispatcherOperation.InvokeImpl()  
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)  
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)  
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)  
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)  
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)  
at System.Windows.Threading.DispatcherOperation.Invoke()  
at System.Windows.Threading.Dispatcher.ProcessQueue()  
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)  
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)  
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)  
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)  
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)  
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)  
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)  
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)  
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)  
at System.Windows.Application.RunDispatcher(System.Object)  
at System.Windows.Application.RunInternal(System.Windows.Window)  
at SourceTree.App.Main()


author: MOHAMOD Shah
body: For time being, I have installed version 3.4.4 and it's working fine. Thank you [@Miro XY](/t5/user/viewprofilepage/user-id/4478373) for the download link.


author: Katrina Stading
body: Installing 3.4.4 worked for me. In all instances where Sourcetree was crashing for me, the repository already contained several files. So Sourcetree isn't just crashing if you try to clone an empty repo.


author: Aidan
body: I encountered this exact same error just recently as well. I found that all I needed to do was actually commit something to the repository (e.g. a readme to the master branch) in order for Sourcetree not to crash when trying to clone. Initially the repository was brand new and empty, which I guess Sourcetree chokes on.

comments: author: Jason Harrington
body: Thanks for your response Aidan. If I encounter this again, I will give it a try.


author: Atanas Harapov
body: Can confirm when opening a new repository without commits it crashes on version 3.4.6.


author: G Salas
body: Also confirmed that trying to clone an empty repository does crash 3.4.5 and 3.4.6.

Thanks for posting this solution!


author: SETS_Insperion
body: Hi, good day. I confirmed as said by [Atanas Harapov](https://community.atlassian.com/t5/user/viewprofilepage/user-id/4535011), version 3.4.6 is still crashed when I tried to clone a repo w/o any branches \& commits.


author: David John Brown
body: I'm a confused newbie. How can I commit to an empty repository when I am unable to clone it?


author: Mark Jeffery
body: Good question, David John Brown.

There are a couple of ways of doing this.

If you created your repository in BitBucket, you can access it by signing in at <https://bitbucket.org>, find your repository, and create a file in it, for example, use the option to create a default .gitignore file. That one file is enough to get around this bug.

Otherwise, you might have to SSH into your server and use command-line git to commit a file, which is really not easy for a newbie. Which is ironic: the whole point of Sourcetree is to avoid the need to use command-line git!

Hope that helps. And I've no idea how to get the attention of the Atlassian team, but please, for pity's sake, if you're reading this: this silly issue is a huge impediment to people's getting going on Sourcetree. Please, please do the simple fix and stop confusing newbies!


author: David John Brown
body: Thank you, Mark Jeffery. I got round it (after some head scratching) by using Git GUI, which I would prefer to have avoided given that I was following a Sourcetree tutorial!


author: SETS_Insperion
body: Greetings David, as said by Mark Jeffery, when you create an empty repository BitBucket suggests making an "Initial Commit" with a README.md and/or with .gitignore file, both of them are in buttons in the repo creation form OR in the instructions when you finish the creation of. This is the common workaround I've found in this community. Regards and have a good day!


author: David John Brown
body: Thank you, SETS_Insperion. I fell into this trap as I was trying to follow step-by-step a very good tutorial which I was using to try to get to grips with Sourcetree. I hated having to break off from the tutorial to workaround the issue. However I'm back on track now, thanks to the internet and, in particular, to this post.


author: Jonathan Boivin
body: Same issue using version 3.4.7. Fixed it creating an empty file on the remote repository.


author: R4DIC4L
body: Fixed it by creating a README file in the Gitlab repo. Thanks, Aidan!


author: Michael Lant
body: Same problem here using 3.4.8.

Solved by cloning a brand new repo using Visual Studio, copying a file (any file) into the new location on-disk. I could then, successfully open SourceTree on the local copy and Commit/Push.

This has been an open issue since July 2021 - eight months. This should be something very easy to fix. What's up?


author: harishismyname
body: Committing a readme file still doesn't work in 3.4.9. Still crashing on clone.


author: Mark Jeffery
body: As suggested by Aiden:

* No need to downgrade to a previous version
* Just commit a file (any file) to your repository and Sourcetree will no longer crash on cloning

Hey, Atlassian folk, could we get a fix for this? It's a strong candidate for a really easy fix:

* well-defined: just clone a repository with no files in it
* reproducible: happens every time!
* recently introduced: it didn't happen in 3.4.4, it does happen in 3.4.5...latest (3.4.6)

Just crashing imposes real costs on users (we have to search the web for a solution, downgrade to an older version and/or work around the issue)... and crashing is not a good look!

Thanks :)

comments: author: Tobias Knauss
body: Still happens in version 3.4.7.


author: harishismyname
body: Committing a file doesn't solve the problem in 3.4.9


author: alex zeleksonov
body: Hi,  
still happing in 2022, version 3.4.9 it pretty sucks, could fix this  

cloning repo from remote URL (amazon)

comments: author: harishismyname
body: Exact remote and version for me too. Still have the problem.


author: Tommy Hamel
body: Anyone got a solution on this i got a user he got the exactly same think and i do all the answer i see on the website and nothing work. I can do the cloning with the terminal but i cannot do it directly in Sourcetree. My version is the latest one 3.4.11 and I got Windows 11 at the latest version too. I really don't know why i cannot clone with Sourcetree can anyone help me please ?

comments: author: Stefan Jonsson
body: Use the old version 3.4.4 as mentioned, that should work.


author: Silvia Ramos
body: Hi,

I had the same issue with version 3.4.7. Upgrading to the latest one (3.4.9) solved the problem.

comments: author: harishismyname
body: I am using 3.4.9 and still have the issue.


author: krembo99
body: This crash bug is still alive [@Ver](/t5/user/viewprofilepage/user-id/1303365).3.4.8 when using other servers ( Gitlab / Gogs / Gitea ) - exactly as OP described - even with non-empty repos.


author: Stefan Jonsson
body: Got the same problem with Sourcetree 3.4.7, did the actions that [Miro XY](https://community.atlassian.com/t5/user/viewprofilepage/user-id/4478373) suggested.

Deleted the folder and use version 3.4.4.

comments: author: Tommy Hamel
body: I use the 3.4.4 and the first clone working but if i restart the computer Sourcetree never open again after.


author: Tobias Arendt
body: Hi, still the same problem in 3.4.7. It's starting to get embarrassing!


author: Oleg Maslennikov
body: Hi everybody, i had faced with same problem and i found there is a error when you make a git clone via console :

Cloning into 'src'...  
warning: You appear to have cloned an empty repository.

So please check your repo on empty and if it's empty just add readme throw web ui

comments: author: harishismyname
body: Adding a file doesn't seem to solve it on 3.4.9


author: Michael Reiff
body: This is my Solution (as a git-Rookie):

1. Create Repository in Bitbucket
2. Open Sourctree
3. In Sourctree: click on Terminal (right, top line)
4. In the Terminal: use the commands cd, cd.. and dir (with TAB) to navigate to an empty Directory
5. In the Bitbucket-Repository: copy the clone-command: "git clone https://............./test-repo-02.git
6. Terminal: paste the command and press Enter
7. Windows-Explorer: go to the Directory and add e.g. a Text-File
8. Sourctree: Add a new Tab and Add the Directory
9. You are ready to commit and push the Repository

Hope this helps someone.

comments: author: ivan80057891
body: Thx, this help me to resolve.


author: selecters75
body: This also worked for me


author: Tom?s
body: Hi,

I'm having the same error in version 3.4.6.

I try to clone a repository, paste the URL, checks if it is a Git repository and them crashes the application.

I'm returning to version 3.4.4 as suggested by Miro XY in one of the answers in this thread.


Tags: atl-gruland

bug