我试图设置git与http://danielmiessler.com/study/git/#website来管理我的网站。
我已经到了指令的最后一步:git push website +master:refs/heads/master
我正在win7中使用git ming32命令行工作
$ git push website +master:refs/heads/master
Bill@***.com's password:
Connection closed by 198.91.80.3
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
这里的一个问题可能是程序正在寻找bill@* **.com。当我通过ssh连接到我的网站,我有一个不同的用户名(让我们说'abc')。也许这个应该是abc@***。com。如果是这样,我不知道如何改变这一点,或者如果我可以推下一个别名
确保你在.git/config中有正确的url
url = git@github.com:username/repo.git
如果这是你第一次推,你需要在正确的上游设置
$ git push -u origin master
你可以检查哪个键被使用:
$ ssh -vvv git@github.com
回复应该包含如下内容:
debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/id_rsa
...
You've successfully authenticated, but GitHub does not provide shell access.
也可以在~/中为ssh定义规则。Ssh /config,例如基于别名:
Host github
HostName github.com
User git
IdentityFile "~/.ssh/id_rsa"
Host git
HostName github.com
User git
IdentityFile "~/.ssh/some_other_id"
您可以为每个别名设置连接到不同的端口,使用不同的用户名等。
我也犯了同样的错误,这让我得到了这个没有帮助的答案。
我试图创建一个新的“裸”存储库,第一次使用以下命令跟踪到NTFS位置:
cd myrepository
git init --bare \\myserver.mycompany.local\myrepository.git
git init
git status
git add .
git status
git commit -m "Initial Commit"
git remote add origin \\myserver.mycompany.local\myrepository.git
git push -u origin master
git status
我的问题原来是在NTFS位置中使用后斜杠而不是前斜杠,当试图添加原点来设置(新的)跟踪上游分支时。
我必须删除原点使用:
git remote rm origin
然后使用预期的正斜杠再次添加原点
git remote add origin //myserver.mycompany.local/myrepository.git
希望这对将来的人有所帮助。
我间歇性地遇到这个问题,大多数时候它不会给出错误消息。对我来说,解决方案是在我的LDAP服务器的IP地址改变之后正确地配置LDAP。
的/etc/gitlab/gitlab.LDAP的rb配置指向一个不存在的IP地址,因此更改主机以指向LDAP服务器的正确主机名解决了这个问题。
要诊断问题,使用gitlab-ctl tail命令来帮助您找到堆栈跟踪。对我来说,我找到了这个stacktrace:
==> /var/log/gitlab/gitlab-rails/production.log <==
Net::LDAP::Error (No route to host - connect(2) for 10.10.10.12:389):
/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/net-ldap-0.16.0/lib/net/ldap/connection.rb:72:in `open_connection'
...
修改/etc/gitlab/gitlab.rb中的主机值
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main:
label: 'My LDAP'
# this was an IP address
# host: '10.10.10.12'
host: 'internal-ldap-server' # this is the fix
port: 389
在更改上面的配置文件之后,一定要重新配置gitlab
gitlab-ctl reconfigure
在极少数情况下,您将得到“致命:无法从远程存储库读取”错误,如在
[user@example.com repo]$ git fetch --all --prune
Fetching origin
exec request failed on channel 0
fatal: Could not read from remote repository.
当Git服务器文件系统已满时。要验证这一点,请运行:
ssh -v ssh://git@yourhost/path/repo.git
如果服务器像这样回复:
...
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/...
SHA256:...
debug1: Server accepts key: /home/...
SHA256:...
Authenticated to linux-git.....com ([xxx.xxx.xx.xx]:xx) using "publickey".
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem full
...
debug1: Remote: PTY allocation disabled.
PTY allocation request failed on channel 0
shell request failed on channel 0
服务器的磁盘空间会被占满。
我知道这个答案不会得到很多人的支持;为了完整起见,添加它。
附注:也可以使用类似
GIT_SSH_COMMAND="ssh -v" git pull
诊断问题。
对我来说非常简单的解决方案,见下面:-
问题
$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
这也会超时
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
这可能有用
$ ssh -T -p 443 git@ssh.github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
覆盖SSH设置
$ vim ~/.ssh/config
# You can also manually open the file and copy/paste the section below
# Add section below to it
Host github.com
Hostname ssh.github.com
Port 443
然后再试一次
$ ssh -T git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.
现在试试克隆(应该有用)
$ git clone git@github.com:xxxxxx/xxxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 15 (delta 0), reused 15 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), 22.90 KiB | 4.58 MiB/s, done.
参考:here =>使用端口443的HTTPS
在Windows 11上使用这些命令解决了我的问题
1. 我打开Git Bash命令并启动ssh-agent。
eval "$(ssh-agent -s)" // this command only work in git bash.
2. 由ssh-key添加
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" //it must be 4096
ssh-add id_rsa
3.检查是否正确添加。
ssh-add -l
4. 在GitHub上上传其公钥为(授权密钥)
cat id_rsa.pub | clip
5. 取消设置任何代理和GIT_SSH变量
unset GIT_SSH
git config --global --unset http.proxy
git config --global --unset https.proxy
6. 必须检查github.com应该解决。
ping github.com
7. 现在检查Github的连接性。
ssh -T git@github.com
输出
主机“github.com(20.207.73.82)”的真实性不可能是
建立。ED25519密钥指纹为
SHA256: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx该密钥是未知的
您确定要继续连接吗
(是的/不/(指纹))?警告:永久添加'github.com'
(ED25519)到已知主机列表。嗨MHamzaRajput !你已经
成功验证,但GitHub不提供shell访问。