简体   繁体   中英

Git and SSH - How to know what address to use?

I need to set up a git repository in the production server so I can upload all my commits. So, these are the steps I followed:

Production Server (Windows Server 2008)

  1. Installed Git
  2. Created an empty repository at inetpub/wwwroot
  3. Installed CopSSH
  4. Created a new user account
  5. Enabled the user with CopSSH
  6. Changed the default directory of the new user to the repository address
  7. Setted environment variables to read Git commands

Development (Windows 7 + Netbeans)

  1. Installed Git
  2. Created a repository right where my project is
  3. Added all files of the project to the repository

Now, I need to upload my dev project to prod. First, I'm checking if the SSH default directory where I'm pointing to is a repository:

$ git ls-remote ssh://user@server/
fatal: '/' 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 tried adding the folder name, ".git", foldername.git, everything, and I get the same error.

Where am I having the issue? Thank you beforehand.

PS I already tested the new default directory and it points right to the empty repository in the server, so it's working.

EDIT: I tried this:

$ git ls-remote user@host:.git
user@host's password:

$_

I got no output. Is that okay?

You're saying the git repository at your server is located at / (say, you should have a /.git directory). As that's probably not true, I'd suggest you to connect via ssh to the server and run pwd (or it's Windows equivalent) to found where your home directory is, and then get the relative path to your repository.

Say, if running pwd right after logging into the server gives you C:\\users\\my_user and your git repository is at C:\\users\\my_user\\git\\my_project , use ssh://user@server:git/my_project as the URL. The : means a relative path from your home directory.

Also you can use an absolute path, as in ssh://user@server/c/users/my_user/git/my_project , or however Windows decides to name your C: partition :)

As you use ssh transport, your syntax tries to access the root of your Copssh installation, Example: if you installed Copssh at c:\\copssh, then your root (/) is the same directory.

Your command git ls-remote ssh://user@server/ tries to access that directory.

Try something like

git ls-remote ssh://user@server /home/user* (c:\\copssh\\home\\user) or

git ls-remote ssh://user@server/cygdrive/d/mygit if your repository is at d:\\mygit)

If you all want to create a Windows based Git repository, you may consider to stick with Gitwin which has a fully functional free edition . It is Git on Cygwin though and Disclaimer: I'm the developer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM