我有一个非常奇怪的问题与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
什么好主意吗?
当前回答
在执行此操作之前,请确保您拥有对回购的写权限。如果您仍然得到错误,请执行以下操作:
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.
其他回答
如果使用私有存储库检查连接用户,则该用户必须具有使用存储库的权限。
我可以解释我是如何陷入类似的情况,然后列出我已经采取的步骤来解决这个问题。
我在用 Windows 10, Git: Git版本2.27.0.windows.1。
我已经安装了git,正在做git推送活动。Windows凭据管理器存储用户名和密码,所以你不必每次git远程活动都输入用户名和密码。
遇到这个问题,当我添加了另一个github帐户和使用——本地git设置。几天后,我遇到了存储库找不到的问题,经过调查我发现:
即使你从Windows凭证管理器中删除了git详细信息,它也会再次保存你输入的用户名、电子邮件详细信息。
因此,如果您使用两个git帐户,则需要使用(以管理员身份使用git bash)
git config --edit --system
然后移除
helper = manager
行,使其不再注册为凭据帮助器。但是每次你进行远程活动时,它都会询问你登录的详细信息。
如何禁用Git凭证管理器的Windows?
检查远程源、用户详细信息
git config --list --show-origin
我也遇到了同样的问题,尝试了很多方法,但最后,我知道我没有足够的权限来推或拉这个回购,还有一种方法来检查你是否有权限,你无法看到该回购中的设置选项,如果你有权限,那么你将能够看到设置选项
谢谢!这是我观察到的
下面为我解决了这个问题。
首先,我使用这个命令来确定使用的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存储库上没有授权。
eval "$(ssh-agent -s)"
这是我自己的回购——应该有足够的使用权。对于其他回购,我能够拉和推没有问题。通过重新启动ssh-agent解决了这个问题。我用macos。