无法访问远程 git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18565876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot access remote git repository
提问by HukeLau_DABA
I created a git repo via the github website's "new button". Then I used git bash to set up my local repo and tried to pull my remote repo (it had the default README) but got an "access denied error", the same one seen in this question: Cannot push to git repository - permission denied
我通过 github 网站的“新按钮”创建了一个 git repo。然后我使用 git bash 来设置我的本地 repo 并尝试拉我的远程 repo(它有默认的自述文件)但是得到了一个“访问被拒绝错误”,在这个问题中看到了同样的错误: Cannot push to git repository - permission denied
I followed https://help.github.com/articles/set-up-git#platform-windows, even reopened a new git bash session but I still get access errors on my remote repo. I chmod 777
on my local repo so it's not a local problem either.
我关注了https://help.github.com/articles/set-up-git#platform-windows,甚至重新打开了一个新的 git bash 会话,但我的远程仓库仍然出现访问错误。我chmod 777
在我的本地仓库,所以这也不是本地问题。
https://github.com/new
to create my new remote repo.- Opened git bash on my win7 computer and executed the following commands:
git init
in project directorygit add .
to recursively add all project filesgit commit -am "commit message"
git remote add origin https://...
produces "fatal: remote origin already exists".git pull origin master
produces access denied error. I tried step 4 first with ssh, now I'm trying to use https.
https://github.com/new
创建我的新远程仓库。- 在我的win7电脑上打开git bash并执行以下命令:
git init
在项目目录中git add .
递归添加所有项目文件git commit -am "commit message"
git remote add origin https://...
产生“致命:远程来源已经存在”。git pull origin master
产生访问被拒绝错误。我首先使用 ssh 尝试了第 4 步,现在我正在尝试使用 https。
采纳答案by NiKiZe
To get push permissions I would use the ssh protocol/uri when doing the first git clone
(since that avoids some config troubles)
为了获得推送权限,我会在第一次使用 ssh 协议/uri git clone
(因为这避免了一些配置问题)
Edit:To possible fix the issues you are now having check your uri since it might be as simple as a spelling mistake
Check current configuration with git config -l
Possibly change with git remote set-url origin [email protected]:path/torepo.git
See more here.
编辑:为了可能解决您现在遇到的问题,请检查您的 uri,因为它可能像拼写错误一样简单,
请检查当前配置,使用git config -l
可能更改git remote set-url origin [email protected]:path/torepo.git
查看更多信息。
回答by Alisa
I am using "GitHub for Windows" and have two Github accounts, sometimes switching from one to the other.
我正在使用“ GitHub for Windows”并有两个 Github 帐户,有时会从一个帐户切换到另一个帐户。
Similarly, I got this error:
同样,我收到了这个错误:
remote: permission to .../....git denied to 93befbc3eeadfe14e.... fatal: unable to access 'https://github.com/....git': The requested URL returned error: 403
远程:.../....git 的权限被拒绝 93befbc3eeadfe14e.... 致命:无法访问“ https://github.com/....git”:请求的 URL 返回错误:403
I solved the problem whithin "Github for Windows" program:
我在“ Github for Windows”程序中解决了这个问题:
- Settings (small gear on the top-right corner) --> Options
- Log out
- Choose "Add account" which is, in fact, the same as "log in". Then used the right account (which the respective repository is belonged to).
- 设置(右上角的小齿轮)--> 选项
- 登出
- 选择“添加帐户”,实际上与“登录”相同。然后使用正确的帐户(各个存储库所属的帐户)。
回答by Jicksy John
Try
尝试
git pull origin master
and then
进而
git push origin master