2

I have installed cygwin on a windows server, solely for use of ssh.

In addition, I've installed Git for Windows, having discounted the use of Cygwin git as it doesn't support the windows extensions.

I have a git ssh user which can login (via ssh) and can create the repositories under this user's home directory. This allows me to push to the server from OSX running SourceTree. In this case, the repository is located with: -

git@GitServer:Repos/Project.git

The actual path to the folder under cygwin is: -

/cygwin/home/git/Repos/Project.git       

However, I want to be able to have the Repos directory placed directly at the root of the cygwin folder, not under a home folder: -

/Repos/Project.git

Doing this causes SourceTree to fail when trying to push to the repo. I'm defining the path like this: -

git@GitServer:/Repos/Project.git

I have also checked permissions on the folders and this is not the issue.

The failure results in this message: -

fatal: '/Repos/Project.git' does not appear to be a git repository

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

I can understand that I'd have problems if the repo was placed outside of the cygwin folder, but should it not be possible for it to be placed at the root and can anyone explain how I can get the SourceTree path to access the repo, if it's placed at the root, without having to create symbolic links?

Community
  • 1
  • 1
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • 1
    You really don't need cygwin: use the openssh embedded in the "Git For Windows" (msysgt) distrib: http://stackoverflow.com/a/19534485/6309 – VonC Jun 19 '14 at 15:41
  • @VonC, from all the documentation I've read, I can only find how I can use msysgit ssh to connect to other servers. How would I set up the Windows server with msysgit ssh to receive connections? I'm setting up a git master repository. – TheDarkKnight Jun 19 '14 at 16:06
  • That is separate from Git. You could use FreeSSHd then (http://serverfault.com/a/8412/783, http://stackoverflow.com/a/18318/6309, http://www.techrepublic.com/blog/tr-dojo/set-up-a-free-ssh-server-on-windows-7-with-freesshd/). A cygwin-like solution would be CopSSH (http://stackoverflow.com/questions/18292/what-are-some-good-ssh-servers-for-windows#comment16257352_958174, https://www.itefix.no/i2/copssh) – VonC Jun 19 '14 at 16:10
  • Thanks, but setting up the ssh server is not the issue, this is detracting from the original question. – TheDarkKnight Jun 19 '14 at 16:11
  • What is the SourceTree error message when trying to access `/Repos/Project.git` through ssh? – VonC Jun 19 '14 at 16:13
  • @VonC, error added to the question. It is as though the user can't escape their home directory. Logging in via ssh directly shows that this is not the case. – TheDarkKnight Jun 19 '14 at 16:20
  • Does `ssh git@GitServer` work? `ssh git@GitServer ls /Repos`? If not, what `ssh -Tvvv git@GitServer` returns? – VonC Jun 19 '14 at 16:21
  • Yes, "ssh git@GitServer ls /Repos" displays the correct result; Project.git – TheDarkKnight Jun 19 '14 at 16:23
  • Just to check, would an url like `ssh://git@GitServer/Repos/Project.git` work better for SourceTree? – VonC Jun 19 '14 at 16:24
  • No, that fails too ;O( – TheDarkKnight Jun 19 '14 at 16:27
  • Strange, since `/` is a valid path: http://stackoverflow.com/q/12311440/6309. Still looking into this. – VonC Jun 19 '14 at 16:29
  • Exactly. I really don't see why it shouldn't work. Thanks for looking into it with me. I suspect it may be something to do with how SourceTree is handling the path. – TheDarkKnight Jun 19 '14 at 16:31
  • I would start by looking in Cygwin for the content of `/etc/sshd_config`, to see if there is an option which doesn't allow ssh client to access `/`. Just to be sure, I would check if I can execute from the client `ssh git@GitServer ls /Repos/Project.git` (make sure the case is right too). – VonC Jun 19 '14 at 16:33
  • Check also the Cygwin sshd logs: `cat /var/log/sshd.log` (as shown in http://stackoverflow.com/q/12319215/6309) – VonC Jun 19 '14 at 16:35
  • Thanks, will do and will get back to you. "ssh git@GitServer ls /Repos/Project.git" works as expected. – TheDarkKnight Jun 19 '14 at 16:35
  • The cygwin sshd log is empty. – TheDarkKnight Jun 19 '14 at 16:36
  • Maybe the log isn't activated in `/etc/sshd_config` – VonC Jun 19 '14 at 16:37
  • A few interesting tutorial to double-check: http://www.cforcoding.com/2009/09/windows-git-tutorial-cygwin-ssh-and.html, https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Tivoli%20Application%20Dependency%20Discovery%20Manager/page/Setting%20up%20a%20Cygwin%20OpenSSH%20Server%20for%20Windows%20Domains%20on%20a%20TADDM%20Gateway%20Server, http://tsengf.blogspot.fr/2011/06/installing-sshd-in-cygwin-on-windows-7.html – VonC Jun 19 '14 at 18:25
  • The first article mentions that you should use cygwin and then doesn't disuss it again. The second describes how I've already setup the system, but I'm non the wiser. Thanks all the same. – TheDarkKnight Jun 20 '14 at 08:06
  • 1
    I've never seen so many comments without a single attempted answer :o – Theodore R. Smith Dec 31 '14 at 10:53
  • I've been struggling with this issue. too. I want to put my repo in `/cygdrive/d/Git`, but once setup, I can't clone it, exact same message as OP. I can make working repos in my home folder, but not outside of it. Did anyone figure this out? – brock Jul 03 '20 at 02:41

1 Answers1

1

So you have a directory with Git repositories placed in the Cygwin's root directory. I will expect, that your Cygwin's root directory is c:\cygwin, so directory with the Git repository is c:\cygwin\Repos\Project.git. Cygwin's root directory is mounted as / in Cygwin, so your Git repository directory is /Repos/Project.git.

SourceTree is native Windows .NET application, so it uses Windows file system and Windows style paths. Therefore if you said SourceTree to look for Git repository in /Repos/Project.git, it was trying to find it in c:\Repos\Project.git, which is obviously wrong. Just set it to proper Windows path in SourceTree and it will work.

It's the same for any Windows application. Cygwin's path is understood only by Cygwin applications. You can use cygpath to convert Cygwin paths to Windows and vice versa. This command for example opens current directory in Cygwin in Windows Explorer:

explorer `cygpath -wa .`

Also repository can be placed anywhere you want of course, it doesn't have to be under Cygwin's root directory. It can be even on a different drive. Cygwin mounts all Windows drives as /cygdrive/<drive-letter> automatically by default, so e.g. d:\Repos is accessible as /cygdrive/d/Repos in Cygwin. You can also create a symbolic link to any directory outside of Cygwin, so you can have e.g. /cygdrive/d/Repos linked as ~/Repos for faster access from Cygwin.

Just one simple rule: under Cygwin use Cygwin style paths, under Windows use Windows style paths.

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68