我有一个非常奇怪的问题与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
什么好主意吗?
当前回答
问题:由于某些原因,Github不熟悉你的存储库。
Error:在git cli中提示如下:
remote:未找到存储库。致命:库 “https://github.com/MyOrganization/projectName.git/”未找到
解决方案:2个选项
Github might not familiar with your credentials: - The first Option is to clone the project with the right credentials user:password in case you forgot this Or generate ssh token and adjust this key in your Github. aka git push https://<userName>:<password>@github.com/Company/repositoryName.git Repo Permissions Issue with some users - In my Use case, I solved this issue when I realized I don't have the right collaborator permissions on Github in my private repo. Users could clone the project but not perform any actions on origin. In order to solve this:
去Github上的仓库->设置->合作者和团队->添加 成员/维护你的用户->现在他们获得了提交的权限 ,推动
其他回答
下面为我解决了这个问题。
首先,我使用这个命令来确定使用的github帐户是什么:
ssh -T git@github.com
这给了我一个这样的答案:
Hi <github_account_name>! You've successfully authenticated, but GitHub does not provide shell access. I just had to give the access to fix the problem.
然后我明白了答案中描述的Github用户(github_account_name)在我试图拉的Github存储库上没有授权。
在执行此操作之前,请确保您拥有对回购的写权限。如果您仍然得到错误,请执行以下操作:
Generate a personal access token from your account from Settings > Developer Settings > Personal Access tokens. Keep the token safe somewhere. Go to your repository and run the following: git remote rm origin Then add a new origin along with your username: git remote add origin https://USERNAME@github.com/REPOSITORY_LINK.git Now when you push the code, a prompt will show up asking for your password or personal access token. Paste the token that we generated in the first step in the field, and we're done.
如上Alex所说,更改.git/config文件的内容会有所帮助。我也遇到了同样的问题,我想这是因为我更改了我的Github用户名。无法使用更改更新本地文件。所以当你改变你的用户名时,你可能会考虑跑步
Git远程添加原点your_ssh_link_from_github
我希望这对你有所帮助;)
一个问题,这可能是显而易见的一些,我没有看到这里提到,可能是你有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为这个回购的设置。
如果你的repo之前工作正常,突然弹出这个错误,最有可能的原因是你的git被认证为其他用户,没有访问存储库的权限。因此,为了进行推送,您所需要做的就是在git命令中指定正确的用户名和密码。所以,一个github回购的推命令看起来像:
git push https://youruser:password@github.com/user/reponame.git
用户名和密码需要进行url转义,因此@应该被%40取代,等等。