简体   繁体   English

无法访问远程git存储库

[英]Cannot access remote git repository

I created a git repo via the github website's "new button". 我通过github网站的“新按钮”创建了一个git repo。 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 然后,我使用git bash设置了本地存储库,并尝试拉出远程存储库(它具有默认的README),但出现了“访问被拒绝错误”,在此问题中也看到了同样的错误: 无法推送到git存储库-权限被拒绝

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. 我遵循了https://help.github.com/articles/set-up-git#platform-windows ,甚至重新打开了一个新的git bash会话,但是我在远程仓库上仍然遇到访问错误。 I chmod 777 on my local repo so it's not a local problem either. 我在本地仓库中使用chmod 777 ,因此也不是本地问题。

  1. https://github.com/new to create my new remote repo. https://github.com/new创建我的新远程仓库。
  2. Opened git bash on my win7 computer and executed the following commands: 在我的win7计算机上打开git bash并执行以下命令:
    1. git init in project directory 项目目录中的git init
    2. git add . to recursively add all project files 递归添加所有项目文件
    3. git commit -am "commit message"
    4. git remote add origin https://... produces "fatal: remote origin already exists". git remote add origin https://...产生“致命错误:远程来源已存在”。
    5. git pull origin master produces access denied error. git pull origin master产生访问被拒绝错误。 I tried step 4 first with ssh, now I'm trying to use https. 我首先使用ssh尝试了步骤4,现在我正在尝试使用https。

I am using " GitHub for Windows " and have two Github accounts , sometimes switching from one to the other. 我正在使用“ 适用于Windows的GitHub ”并有两个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 ”程序中的问题:

  1. Settings (small gear on the top-right corner) --> Options 设置(右上角的小齿轮)->选项
  2. Log out 登出
  3. Choose "Add account" which is, in fact, the same as "log in". 选择“添加帐户”,它实际上与“登录”相同。 Then used the right account (which the respective repository is belonged to). 然后使用正确的帐户(各个存储库所属的帐户)。

To get push permissions I would use the ssh protocol/uri when doing the first git clone (since that avoids some config troubles) 为了获得推送权限,我将在执行第一个git clone时使用ssh协议/ uri(因为这避免了一些配置麻烦)

Edit: To possible fix the issues you are now having check your uri since it might be as simple as a spelling mistake 编辑:为了可能解决您现在正在检查uri的问题,因为它可能像拼写错误一样简单
Check current configuration with git config -l 使用git config -l检查当前配置
Possibly change with git remote set-url origin git@github.com:path/torepo.git See more here . 可能使用git remote set-url origin git@github.com:path/torepo.git更改git remote set-url origin git@github.com:path/torepo.git 在此处查看更多信息

Try 尝试

git pull origin master

and then 接着

git push origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM