Git “does not appear to be a git repository” ip an

2019-03-12 19:29发布

问题:

I'm trying to commit my first Git repository to a gitlab instance, which I've set up on a debian-VM. Everything is going to happen via local network. The following commands are shown in gitlab after creating a new repo.

mkdir test
cd test
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@10.200.3.248:1337:Matt/test.git
git push -u origin master

After entering git push -u origin master this happens:

git@10.200.3.248's password:
fatal: '1337:Matt/test.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.

Could the problem be the port on which Git is running at? Gitlab is accessible through port 617 so I'am able to reach the GUI via http://xxx.xxx.xxx.xxx:617/Matt/test

The password I've entered seems to be correct, because a wrong password will end up in a "permission denied" message. OT: I don't know why I've to enter a passwd, because I've generated and added ssh-keys, as described in gitlab, but that's an other problem.

回答1:

I've solved my problem. The given port 1337 wasn't the problem, although it was wrong too, because ssh does not seem to be able to handle a port in url:

Using a remote repository with non-standard port

The Git-url which worked for me was:

git@10.200.3.248:repositories/Matt/test.git

My Git user home dir is located in /home/git/ and the repositories are stored in /home/git/repositories so i had to add repositories to my Git-path.

The reason why GitLab told me to use the url git@10.200.3.248:1337:Matt/test.git seems to be a wrong configured Git path in GitLab. I'll try to fix this now.

Edit:

The wrong host was configured in /home/git/gitlab/config/gitlab.yml. The "host" there must be without port... There is an extra option for the port if needed.

Edit3: Still unable to push or fetch my test-repository without repositories in path.. https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide#could-not-read-from-remote-repository

Maybe something to do with rsa-keys but I don't understand how this belongs together.

Edit4: (Problem(s) seem to be solved) My rsa-keys were ok. The problem was that I've configured my sshd_config to allow only a certain user for ssh-login. I've simply added Git to the list of allowed users AllowUsers mylogin git

Now I don't have to login via password anymore (You never have to login via password if ssh rsa keys are set up correctly) and the path works without "repositories" as it should. Now I understand, that this is just a normal ssh-connection - I hadn't realized this before..

The way I figured it out:

login via terminal as root:

service ssh stop #Current SSH-Connection won't be closed..
/usr/sbin/sshd -d

====debugging mode===

Then in Git Bash:

ssh -Tv git@gitlab.example.com

Afterwards the terminal with sshd running in debug mode has thrown an error that Git is not allowed to login because of AllowUsers...

Don't forget to start your ssh service afterwards:

service ssh start


回答2:

use this format:

git remote add origin ssh://git@xxx.xxx.xxx.xxx:1337/Matt/test.git

user@host:[port]/path in most cases, we omit the port and it looks like this: user@host:/path ....



标签: git gitlab