Git“似乎不是一个git存储库”IP和端口而不是域?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16912542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git "does not appear to be a git repository" ip and port instead of domain?
提问by mat
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.
我正在尝试将我的第一个 Git 存储库提交到我在 debian-VM 上设置的 gitlab 实例。一切都将通过本地网络发生。创建新的 repo 后,gitlab 中会显示以下命令。
mkdir test
cd test
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin [email protected]:1337:Matt/test.git
git push -u origin master
After entering git push -u origin master
this happens:
进入后出现git push -u origin master
这种情况:
[email protected]'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
问题可能出在 Git 运行的端口上吗?Gitlab 可通过端口 617 访问,因此我可以通过http://xxx.xxx.xxx.xxx:617/Matt/test访问 GUI
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.
我输入的密码似乎是正确的,因为错误的密码最终会出现“权限被拒绝”消息。OT:我不知道为什么我必须输入密码,因为我已经生成并添加了 ssh 密钥,如 gitlab 中所述,但这是另一个问题。
回答by mat
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:
我已经解决了我的问题。给定的端口 1337 不是问题,尽管它也是错误的,因为 ssh 似乎无法处理 url 中的端口:
Using a remote repository with non-standard port
The Git-url which worked for me was:
对我有用的 Git-url 是:
[email protected]: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.
我的 Git 用户主目录位于/home/git/
并且存储库存储在其中,/home/git/repositories
因此我必须将存储库添加到我的 Git 路径中。
The reason why GitLab told me to use the url [email protected]:1337:Matt/test.git
seems to be a wrong configured Git path in GitLab. I'll try to fix this now.
GitLab 告诉我使用 url 的原因[email protected]:1337:Matt/test.git
似乎是 GitLab 中配置错误的 Git 路径。我现在会尝试解决这个问题。
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.
中配置了错误的主机/home/git/gitlab/config/gitlab.yml
。那里的“主机”必须没有端口......如果需要,端口还有一个额外的选项。
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
Edit3:仍然无法在没有repositories
路径的情况下推送或获取我的测试存储库..
https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide#could-not-read-from-remote -存储库
Maybe something to do with rsa-keys but I don't understand how this belongs together.
也许与 rsa-keys 有关,但我不明白这是怎么回事。
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
Edit4:(问题似乎已解决)我的 rsa-keys 没问题。问题是我已将 sshd_config 配置为仅允许特定用户进行 ssh 登录。我只是将 Git 添加到允许用户列表中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..
现在我不必再通过密码登录(如果 ssh rsa 密钥设置正确,您永远不必通过密码登录)并且该路径无需“存储库”即可正常工作。现在我明白了,这只是一个普通的 ssh 连接——我以前没有意识到这一点..
The way I figured it out:
我想出来的方法:
login via terminal as root:
以 root 身份通过终端登录:
service ssh stop #Current SSH-Connection won't be closed..
/usr/sbin/sshd -d
====debugging mode===
Then in Git Bash:
然后在 Git Bash 中:
ssh -Tv [email protected]
Afterwards the terminal with sshd running in debug mode has thrown an error that Git is not allowed to login because of AllowUsers...
之后,在调试模式下运行 sshd 的终端抛出了一个错误,即由于 AllowUsers 不允许 Git 登录...
Don't forget to start your ssh service afterwards:
之后不要忘记启动您的 ssh 服务:
service ssh start
回答by loveni
use this format:
使用这种格式:
git remote add origin ssh://[email protected]:1337/Matt/test.git
git remote add origin ssh://[email protected]:1337/Matt/test.git
user@host:[port]/path
in most cases, we omit the port and it looks like this: user@host:/path
....
user@host:[port]/path
在大多数情况下,我们省略了端口,它看起来像这样:user@host:/path
....