Home > Blockchain >  Difference between ssh:// and git@ version of git connection string
Difference between ssh:// and git@ version of git connection string

Time:11-28

I am trying to use the git server docker image to set up a local git server.

My docker-compose config is this:

  git-server:
    image: jkarlos/git-server-docker
    restart: always
    ports:
      - "22:22"
    volumes:
      - ./docker/git-server/keys:/git-server/keys
      - ./docker/git-server/repos:/git-server/repos

With this setup, of the following two versions, the first one works while the second one does not.

git clone ssh://git@localhost/git-server/repos/my_repo.git
git clone git@localhost:git-server/repos/my_repo.git

The second version gives this error message:

Cloning into 'my_repo'...
fatal: 'git-server/repos/my_repo.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 had thought that these two versions were the same, but that's clearly wrong. What is the difference?

CodePudding user response:

the first one works while the second one does not.

git clone ssh://git@localhost/git-server/repos/my_repo.git

Yes, it accessed the absolute path /git-server/repos/my_repo.git

git clone git@localhost:git-server/repos/my_repo.git

It tries and access the relative path git-server/repos/my_repo.git

Using an absolute path should work better:

git clone git@localhost:/git-server/repos/my_repo.git
                        ^^^^

Or, if the repository is not at /git-server, but, /another/path/to/git-server/...

git clone git@localhost:/another/path/to/git-server/repos/my_repo.git
                        ^^^^^^^^^^^^^^^^^^^^^^
                        # full and complete path
  •  Tags:  
  • git
  • Related