简体   繁体   中英

Permission denied on `git push` after transferring repo to new Github organization

I recently setup a public repo, built a simple app and everything worked as expected.

Eventually I decided the repo should live under a public organization to help encourage contributions. So I created a new organization then transferred the repo to the new organization. I'm setup as the owner (and only member) of this organization.

I then updated the remote on my local using:

git remote set-url [new org repo URL]

A git remote -v displays the new org repo URL.

I made a few more edits (to update the links to the repo in the README) and did a git push origin master to push the changes to the new repo.

And got:

remote: Permission to [new org repo URL] denied to [user].
fatal: unable to access 'https://[user]@[new org repo URL]': The requested URL returned error: 403

A git pull origin master returns successfully.

I have also tried:

  • Changed the default permission for members of the org to both Write and Admin
  • Deleted my local repo, then cloned from the new org repo URL, then tried pushing again
  • Created a team under the new org, then added the repo to that team with Admin permissions

But still get the Permission Denied issue.

What other git, repo, and/or org permissions changes do I need to make?

In your project folder,

  • Go to .git folder and edit the config file.

  • find url= entry under section [remote "origin"]

  • change the url to ssh://git@[new org repo URL]
  • save config file and quit.

Now you can do git push origin master and it should work

EDIT

Using ssh is an alternative to https . You should have been asked for a GitHub username and password when you cloned your repo (assuming you used https ). If you have enabled two-factor authentication, or if you are accessing an organization that uses SAML single sign-on, you must provide a personal access token instead of entering your password for HTTPS Git. This error can occur if you are using an old version of git.

Switching to an SSH URL is one workaround.
But regarding the HTTPS URL, do check:

  • if your account has 2FA activated
  • if you have a Git credential helper check the returned value of git config credential.helper). If yes, remove any GitHub entry , and try a push again: that will prompt for your GitHub credentials (again, if you don't have 2FA).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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