可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am trying to set git up with http://danielmiessler.com/study/git/#website to manage my site.
I have gotten to the last step in the instructions: git push website +master:refs/heads/master
I am working using the git ming32 command line in win7
$ 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.
One problem here may be that the program is looking for Bill@***.com. when I connect via ssh to my site I have a different username( lets say 'abc'). so maybe this should be abc@***.com. If so I don't know how to change this or if I can push under an alias
回答1:
You can specify the username that SSH should send to the remote system as part of your remote's URL. Put the username, followed by an @
, before the remote hostname.
git remote set-url website abc@***.com:path/to/repo
回答2:
Make sure you have correct url in .git/config
url = git@github.com:username/repo.git
If it's your first push, you'll need to set up correct upstream
$ git push -u origin master
You can check which key is used by:
$ ssh -vvv git@github.com
The reply should contain something like this:
debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/id_rsa
...
You've successfully authenticated, but GitHub does not provide shell access.
Also it's possible to define rules for ssh in ~/.ssh/config
, e.g. based on aliases:
Host github
HostName github.com
User git
IdentityFile "~/.ssh/id_rsa"
Host git
HostName github.com
User git
IdentityFile "~/.ssh/some_other_id"
You can set connect to different ports, use different username etc. for each alias.
回答3:
Your ssh key most likely had been removed from ssh agent
ssh-add ~/.ssh/id_rsa
where id_rsa is a ssh key associated with git repo
回答4:
I was facing same issue a while ago...
my .git/config had
url = git@github.com:manishnakar/polymer-demo.git
I replaced it with
url = https://github.com/manishnakar/polymer-demo.git
and it works now:)
回答5:
Try removing the GIT_SSH environment variable with unset GIT_SSH
. This was the cause of my problem.
回答6:
This is usually caused due to the SSH key is not matching with the remote.
Solutions:
Go to terminal and type the following command (Mac, Linux) replace with your email id.
ssh-keygen -t rsa -C "you@email.com"
Copy the generated key using following command starting from word ssh.
cat ~/.ssh/id_rsa.pub
- Paste it in github, bitbucket or gitlab respective of your remote.
- Save it.
回答7:
After doing some research I've finally got solution for this, you have declared a environment variable to plink.exe path. So if you remove that path, reopen the git bash and try cloning through SSH it will work.
Refer to this link
http://sourceforge.net/p/forge/site-support/2959/#204c
回答8:
I had the same problem.
This error means that you have not specified your remote URL location upon which your code will push.
You can set remote URL by 2 (mainly) ways:
Specify remote URL via executing command on Git Bash.
Mention remote URL direct in config file
Navigate to your project directory
Move to .git folder
Open config file in text editor
Copy and paste below lines
[remote "origin"]
url = https://abc.xyz/USERNAME/REPOSITORY.git
fetch = +refs/heads/*:refs/remotes/origin/*
For more detailed info visit this link.
回答9:
I had the same error.
The solution was following:
I've corrected my url in .git/config
.
Just copied that from HTTPS clone URL. That would be something like that:
url = https://github.com/*your*git*name*/*your*git*app*.git
It worked.
回答10:
Make sure ssh-agent is running:
eval "$(ssh-agent -s)"
https://help.github.com/articles/generating-ssh-keys/#step-3-add-your-key-to-the-ssh-agent
回答11:
If you use Gitlab than you might need to log in and accept Gitlab new terms, before you try to pull or push.
回答12:
In your .git/config file
[remote "YOUR_APP_NAME"]
url = git@heroku.com:YOUR_APP_NAME.git
fetch = +refs/heads/*:refs/remotes/YOUR_APP_NAME/*
And simply
git push YOUR_APP_NAME master:master
回答13:
Another workaround:
Sometimes this happens to me because of network problems. I don't understand the root problem fully, but switching to a different sub-network or using VPN solves it
回答14:
For my case, I am using Corporate network (without internet connection) in office. In order to pull code from github, I set https proxy in gitbash and then use https instead of ssh to pull code,it works fine. However when comes to push code, the https proxy won't work. So either switch to Internet network (with internet connection) or set ssh proxy can solve the problem.
回答15:
In my case I was using an ssh key with a password to authenticate with github. I hadn't set up pageant properly in Windows (only in cygwin). The missing steps were to point the git_ssh environment variable to plink.exe. Also, you need to get github.com into the plink known_hosts.
plink github.com
y
<then ctrl-c>
Hope this helps!
I sure wish intellij would have given me a more useful error, or better yet asked me to type in the ssh key password.
回答16:
If after"git push origin master" command u see the error "could not read from remote repository" then try this out
1.ssh-keygen -t rsa -b 4096 -C "youremail"
2.eval $(ssh-agent -s)
3.ssh-add ~/.ssh/id_rsa
4.clip < ~/.ssh/id_rsa.pub(it copies the ssh key that has got generated)
5.then go to your remote repository on github and goto settings-> SSH and GPG keys ->new SSH key ->enter any title and paste the copied SSH key and save it
6. now give git push origin master
回答17:
i just wanted to share that i found a easy fix for that:
Access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
just logout from gitlab and login again. The problems should then be fixed.
回答18:
Actually I tried a lot of things to make it work on Win7, since changing the SSH exectun fron native to build-it and backwards and the same error.
By chance, i change it to HTTPS in the ".git/config" file as:
[remote "origin"]
url = https://github.com/user_name/repository_name.git
fetch = +refs/heads/*:refs/remotes/origin/*
and it finally worked. So maybe it could work for you as well.
回答19:
I had the same issue and after a while I saw I'm under root user (with sudo -s). May this help for someone.
回答20:
According to my experience, one of the reasons this problem occured is because you have an unstable internet connection.
回答21:
I had a perfectly fine working git and suddenly I got that error when I tried to push to the master. As I found out, it was because the repository host had problems.
If you using GitHub or Bitbucket you can easily check the status at
https://status.github.com/messages or https://status.bitbucket.org/
![](https://www.manongdao.com/static/images/pcload.jpg)
回答22:
For those having this problem on a private remote repo. make sure you have accepted the Xcode agreement on the remote server: it took we weeks to find out this fix
Use this command from the command line: sudo xcodebuild -license
回答23:
I just wanted to add to this question. I had Git setup to use PLink and Pageant for authentication and I was also getting the error FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
. I had Pageant opened but the error was still showing up. The problem? I didn't have the private key loaded in Pageant (to add a key, follow these instructions). It was that simple.
回答24:
When using putty/pageant, make sure you did not forget to add the correct SSH key to pageant, else this error shows up. DUH
回答25:
In my case it was the postBuffer..
git config --global http.postBuffer 524288000
For reference read: https://gist.github.com/marcusoftnet/1177936
回答26:
Go to MINGW32 terminal put this Command : git branch --set-upstream-to=origin/(branch Name)
回答27:
If you are still getting the same error, please make sure that in the git settings->ssh tab->ssh client to use is set to openSSH![](https://www.manongdao.com/static/images/pcload.jpg)
回答28:
I had the same error, which brought me to this answer that didn't help me.
I was trying to create a new "bare" repository for the first time using the commands below to track to an NTFS location:
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
My problem turned out to be using the back slashes instead of forward slashes in the NTFS location when trying to add origin to set the (new) tracked upstream branch.
I had to remove the origin using:
git remote rm origin
Then add the origin again using the expected forward slashes
git remote add origin //myserver.mycompany.local/myrepository.git
Hope this helps someone in the future.
回答29:
I've got this error after changing computers. I'm using SourceTree with Bitbucket.
So I had to add the SSH key generated by SourceTree, on the new computer, in Bitbucket Settings > Security > SSH keys, while connected to my Bitbucket account on the web.
回答30:
I faced the same issue; simply you can run this on your command window:
git remote add origin https://your/repository/url