0

I use

git remote set-url origin https://ooker777@github.com/QuaCau-TheSphere/LandofSpheres.git

But why can't I push?

git push
remote: Permission to QuaCau-TheSphere/LandofSpheres.git denied to ooker777.
fatal: unable to access 'https://github.com/QuaCau-TheSphere/LandofSpheres.git/': The requested URL returned error: 403

I am the creator of the organization and the admin of the repo so I must have permission. I pushed successfully before, so it shouldn't be SSH stuff. I don't understand why it happens today.

Ooker
  • 1,969
  • 4
  • 28
  • 58
  • 403 can be a rate limit issue... Which usually resolves itself in ae hour or so... – jessehouwing Nov 27 '22 at 10:09
  • It has been several days, so it shouldn't be connection issue – Ooker Nov 27 '22 at 10:10
  • You're using `https://` so Git is not attempting to use ssh. Git is only using https. Is your (presumably cached or stored or keychain-accessed) password on your local computer the/a correct GitHub token for `ooker777`? Does `ooker777`, with that token, have write access to that repository? (Remember that some GitHub tokens have fine-grained permissions. They also can expire very quickly, depending on how you set them up.) – torek Nov 27 '22 at 10:21

2 Answers2

2

To avoid opening GitHub Desktop and signing in again, check your credential helper

git config --global credential.helper

Then, assuming for instance, manager-core, check what is registered for your user:

printf "host=github.com\nprotocol=https\nusername=ooker777" | git credential-manager-core get

If you don't see anything, register your PAT (Personal Access Token) (assuming one which does not expire)

printf "host=github.com\nprotocol=https\nusername=ooker777\npassword=ghp_yourToken" | git credential-manager-core store

That way, you won't have to sign in again.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Can you explain why the command must be piped like that and not a direct storing command like `git remote set-url ...`? And plus, this is a public repo and I haven't set any permission. I thought that you only need an email to be able to push? – Ooker Dec 02 '22 at 18:09
  • 1
    @Ooker That command is only for storing/getting the credentials needed to push (even to a public repository). The email has nothing to do with remote repository *authentication* but is used for *local* commits *authorship*, local commits that you then push. – VonC Dec 02 '22 at 18:16
  • but why not something like `git credential-manager-core store password myToken`? // So even if I don't use github and set my own git server, I (as the upstream) need to have a way to authenticate my downstream, and I (as the downstream) has to prove that I am indeed me? – Ooker Dec 02 '22 at 18:21
  • @Ooker That command only takes args from stdin, hence the pipe. The credentials is only to be use when pushing to the upstream remote repository. Since said remote is a public one, the downstream repo (the local one) does not need credentials to clone/pull from upstream. – VonC Dec 02 '22 at 19:36
  • I open 2 new questions regarding this: [Why doesn't `git credential-manager-core` accept arguments?](https://stackoverflow.com/q/74665591/3416774), and [Why does `git config --global credential.helper` show wincred when it seems that I'm using Git Credential Manager Core?](https://stackoverflow.com/q/74665534/3416774). I hope to see you there.// Just to confirm, it is that any git server needs to setup an authentication functionality so that other repos can push to it. Am I correct? – Ooker Dec 03 '22 at 09:52
0

I was somehow signed out from GitHub. I open GitHub Desktop to sign in and it works again

Ooker
  • 1,969
  • 4
  • 28
  • 58