我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
我添加了遥控器:
git remote add origin git@github.com:account-name/repo-name.git
什么好主意吗?
我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
我添加了遥控器:
git remote add origin git@github.com:account-name/repo-name.git
什么好主意吗?
当前回答
Normally it happens because the project is private and you have not rights to write it. I had the same "problem" a few times, and it was for that reason. If the project it is yours, just create a private and a public key following this link: https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent and add them to the "SSH and Key" section on gitHub, then you will be able to push to the repo. In the other hand if the project it is not your, ask the owner to give you the rights for it.
其他回答
如果你在Windows上使用Git,试着清除你的凭证:
找到“凭据管理器”(应该在控制面板中) 删除所有与GitHub相关的凭证
检查是否具有读写权限。
Git错误消息具有误导性。我也遇到过类似的问题。我被添加到一个现有的项目中。我克隆了它并提交了一个本地更改。我去推,得到了ERROR: Repository not found。错误消息。
将我添加到项目的人给了我对存储库的只读访问权。他们做出了改变,我得以推动。
一个问题,这可能是显而易见的一些,我没有看到这里提到,可能是你有ssh密钥访问,但你正试图通过https连接你的本地回购到远程。
如果是这种情况,那么下面的命令应该可以解决这个问题:
$ git remote -v
origin https://github.com/private-repo.git (fetch)
origin https://github.com/private-repo.git (push)
$ git remote rm origin
$ git remote add origin git@github.com:private-repo.git
$ git remote -v
origin git@github.com:private-repo.git (fetch)
origin git@github.com:private-repo.git (push)
请注意,上述工作的前提是: 您当前的远程名为origin,并且您已经拥有 生成SSH密钥连接到您的github帐户 你已经有一个SSH密钥与你的github帐户相关联(并在本地连接) 你有正确的权限(读/写)设置在github为这个回购的设置。
这对我来说很管用:
1. 的遥控器
$ git remote rm origin
$ git remote add origin git@github.com:<USER>/<REPO>.git
如果您的SSH密钥已经在另一个github代表上使用,您可以生成一个新密钥。
2. 生成新的SSH密钥
$ ssh-keygen -t rsa -b 4096 -C "web@github.com"
3.在SSH代理级别添加密钥
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa_github
4. 将新密钥添加到Github回购。
我在一台MAC上遇到了同样的问题,试图从我以前连接到的一个私人回购中提取。
我通过在回购url中包含我的用户名来解决这个问题:
git remote set-url origin https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git
然后我从回购中提取了数据。
对于一个你想克隆的新回购:
git clone https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git
它会提示你输入那个账户的密码,然后你就可以去了。