SSH connecting to a local server... default user directory ignored

I am trying to configure SSH on a windows server and I'm attempting to connect to it with SourceTree.

The server is Windows 2008 R2, with Bitvise SSH installed, configured and running as expected. (I can SSH in via putty... everything is working as expected)

In both Bitvise and git, I have configured the default / starting directories to be D:\ (the data drive, large enough to hold all of our repositories)

When I'm on the server, running a shell window (sh.exe --login -i) opens the the D drive as I would expect... as does an SSH connection via putty... but when I attempt to connect to the server using SourceTree... I am told that the folder I'm browsing to "doesn't appear to be a git repository"

This obviously suggests a pathing problem, and with further log diving... I have confirmed this to be the case.

My Actual structure:


SourceTree is attampting to find my project at:

C:\Program Files(x86)\Git\repo\project.git

Here is the connection URL I am using:


Checking my server SSH logs... I can see that the following command is running when SourceTree connects:

sh.exe --login -i -c "git-upload-pack '/repo/project.git'"

And I recieve the following error message:

fatal: protocol error: bad line length character: Welc
fatal: 'C:\Program Files (x86)\Git\repo\project.git' does not appear to be a git repository

This is, of course, true... there is no repo at that location... but if I execute "sh.exe --login -i" on the run dialog on the server... the path is correctly opened to the D drive.

I'm sure that I'm just missing something simple here...

What do I need to do to force the starting directory to be D:\ rather than C:\...\Git when SourceTree connects to a local server?

Please note that I can successfully clone this repo if I use the file protocol (the D drive on this server is a network share)... but this is far too slow for production use.

Thank you for your help!

James Carpenter

3 answers

1 accepted

So for anyone finding this question... here are the steps to fix the problem I was having.

  • on the server, I had to edit the /etc/profile file and add the following line

just above the following:
# normalize HOME to unix path
HOME="$(cd "$HOME" ; pwd)"

This hard coded the home directory in git to the D drive for all users (which is where our repos are located).

After making this fix... it uncovered another problem that was causing SourceTreet to die.

The Message of the Day /etc/motd had some default text in it... which was printing out each time a user connected over ssh... and SourceTree was choking on it. Removing the text from this file fixed the final error we were running into.

Any ideas?

I have tried everything I can think of but everything is resulting in the same error.

A little diheartend by the total lack of support here... does noone have any experience to even provide a suggestion?

Here is a screenshot of a PuTTY connection...

  1. upon connecting to the server over SSH, I am correctly set to the D drive
  2. upon running sh.exe doing nothign but running a PWD command... I am also presented with the correct directory

regardless of what I do, I am presented with the following dialog in SourceTree:

Anyone have ANY ideas? This looks to be a git setup issue... but I can't figure out what to do differently...

I have been reading through mountains of documentation without any success.

The basic question is:

How go I make git start all my users off in the D:\ directory rather than the C:\Program Files(x86)\Git directory?

Thank you for your help

Suggest an answer

Log in or Join to answer
Community showcase
Jason Wong
Published yesterday in Agility Beta

Welcome to agility

Every team in the world is unique, and so   Atlassian believes   that each and every team's best way of working  needs to  be molded to their unique circumstances  – ...

391 views 6 16
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot