2

I am on Mac OSX, git version 1.8.5.2 (Apple Git-48)

I had a git submodule in a git repo that had (to my knowledge) only ever been cloned, pulled, committed, merged and pushed using one git user and rsa key. I have many other pairs of users and keys but no others were specified in the ~/.gitconfig file.

When this submodule had the remote of https://github... etc. It would allow me to commit with the correct username and email being applied but when pushing, would tell me that:

remote: Permission to some_username/project.git denied to user2.
fatal: unable to access 'https://github.com/some_username/project.git/': The requested URL returned error: 403

However when I removed the https://... remote and instead used the git@github.com:some_username/project.git remote, it works correctly.

Is this a bug with git or github? Was there any other way to fix it? Both these users have their associated rsa keys associated on their github accounts.

Josef E.
  • 2,179
  • 4
  • 15
  • 30
AJP
  • 26,547
  • 23
  • 88
  • 127

1 Answers1

3

Is this a bug with git or github?

No: with https url, you need to add the login in the url for git to know what credential to ask for:

cd /path/to /your/submodule
git remote set-url origin https://yourLogin@github.com/yourLogin/yourRepo

An ssh url would use automatically your key (in $HOME/.ssh/id_rsa.pub) which, if published to your account (and if your account is the owner or collaborator of the GitHub repo)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The link ( stackoverflow.com/a/5343146/477878 ) @JoachimIsaksson gave above is well worth a read. – AJP Jun 03 '14 at 17:43