Cannot access remote git repository

心不动则不痛 提交于 2019-12-09 02:13:56

问题


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

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.

  1. https://github.com/new to create my new remote repo.
  2. Opened git bash on my win7 computer and executed the following commands:
    1. git init in project directory
    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".
    5. git pull origin master produces access denied error. I tried step 4 first with ssh, now I'm trying to use https.

回答1:


To get push permissions I would use the ssh protocol/uri when doing the first git clone (since that avoids some config troubles)

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 git@github.com:path/torepo.git See more here.




回答2:


I am using "GitHub for Windows" and have two Github accounts, sometimes switching from one to the other.

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

I solved the problem whithin "Github for Windows" program:

  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).



回答3:


Try

git pull origin master

and then

git push origin master


来源:https://stackoverflow.com/questions/18565876/cannot-access-remote-git-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!