how to reslove 'ssh-agent' failed with code-1: System.NullReferenceException: Object reference not set to an instance of an object.
Asked by abhijeet Kamle:

I currently up source tree to latest version of source tree i.e 1.8.1 and then I try to open the source tree, i am facing some error message like "how to reslove 'ssh-agent' failed with code-1: System.NullReferenceException: Object reference not set to an instance of an object." can some one please help me to resolve the issue.  
[](https://community.atlassian.com/t5/Sourcetree-questions/how-to-reslove-ssh-agent-failed-with-code-1-System/qaq-p/282052?attachment-id=2581){#link_11699b6de95659}  
[](/tnckb94959/attachments/tnckb94959/sourcetree-questions/8762/1/image2016-2-17%2012%3A3%3A36.png){#display_11699b6de95659_0}


Answers:
author: Nukezm
body: Install newest version of git

comments: author: danchadwick
body: +1. The update process for the internal version of git failed to install, but I was able to switch to the system git, update from 1.8 to 2.7, and the ssh-agent issue was resolved.


author: Sukanya Naramreddy
body: same issue i am getting git version is 2.6.3 and source tree version is 2.3.5 so please help me how to resole it.

Awaiting for response!


author: Kamil B
body: Atlassian! seriously?!

Best solution... uninstall this s...


author: ankti patel
body: I updated git bash and integrate to the source tree via Tool \> Option \> Git \> Use System Git  

It worked

comments: author: abhijeet Kamle
body: I fallow same steps, but having same error message window comes.

image2016-2-17 12:3:36.png


author: ankti patel
body: Step I did :

1\> Update embedded Git (Tool \> Option \> Git \> "Update Embedded Git" - button)

This will download PortableGit.7z at "\<user-folder\>\\AppData\\Local\\Atlassian\\SourceTree"

2\> Extract PortableGit.7z

3\> Use as system git (Tool \> Option \> Git \> Use System Git)

select "\\bin\\git.exe" from extracted folder


author: abhijeet Kamle
body: I fallow same step except in step 3 i select Use Embedded Git option and issue has gone. thanks


author: jose suarez
body: Excellent, I got same issue and like said Kamle I just select "Use Embedded Git" option too and work, thanks!


author: Teenage
body: [ankti pate](https://answers.atlassian.com/questions/users?username=ankit.viramgama764771979) answer did the job, but Sourcetree auto upgrade failed, it could not dezipp the PortableGit.7z.

This is how I managed to fix it :

1. Launch update Embedded Git (tools/options/git)
2. If it failed : close sourcetree
3. Go to "\<user-folder\>\\AppData\\Local\\Atlassian\\SourceTree"
4. Rename git_local to git_local_old
5. Unzipp PortableGit.7z manually (with 7zip)to git_local
6. restart sourcetree
7. Go to (tools/options/git and check that Use Embedded Git is hcecked and the version is 2.6.1


author: Mukesh Kumar
body: Hi [@abhijeet Kamle](/t5/user/viewprofilepage/user-id/664612) , [@Sukanya Naramreddy](/t5/user/viewprofilepage/user-id/2180435) , [@danchadwick](/t5/user/viewprofilepage/user-id/630656) , [@Teenage](/t5/user/viewprofilepage/user-id/525371)

Reinstalling Sourcetree resolves that Error.  

Sometime few users also reported ssh-agent issue related to **User account permission**. There can be other instances too but in this particular issue, we have the following reason.

**When Sourcetree crashes:**

If the **ssh-agent** process is already running under **Admin Privileges** and Sourcetree (does not have Admin Privileges) tries to access it, then it can not (Windows don't allow it). So if 'OpenSSH Authentication Agent' service (ssh-agent) is already started automatically on windows startup as Admin then Sourcetree will crash when it tries to access the ssh-agent process.

**When Sourcetree works fine:**

If the ssh-agent process is not already running/started then Sourcetree launches the ssh-agent process under its own access privileges and everything works fine.

**Solution:**   
**Kill the already running ssh-agent process in Services in Task Manager and try re running Sourcetree as it can launch its own ssh-agent under his access rights.**   
If any user is having this issue we are showing following error message and suggestion to resolve the issue:  
![](https://jira.atlassian.com/secure/attachment/441189/441189_image-2023-07-17-17-44-39-124.png)


author: Tomasz Bednarski
body: @Craig Chapman is right. Installing newest version is solution in this problem. It also helped me.


author: abhijeet Kamle
body: I installed git version 1.9.5 but still facing same issue.


Tags: ssh

ssh-key