Search code examples
gitgithuborganizationownership

Trying to create a new repo but git thinks I'm an organization


(some important background): I am an owner of my work's github repo. for this example I will call it "organization/organization"

So,I created some personal, side-project code and decided, afterwards, to push this to a new repo. I created a new repo at github.com. Then did:

git init
git add -A
git commit -am "first commit"
git remote add origin [email protected]:fakename/testapp.git
git push -u origin master

Everything works until that last command:

git push -u origin master

I then get this error:

ERROR: Permission to fakename/testapp.git denied to organization/organization.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Why does git think I'm an organization?!?! Here's my config:

user.name=Mad Jon
[email protected]
core.ignorecase=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=false
[email protected]:fakename/testapp.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

I'm not doing anything to do with my organization. I don't know why it thinks I'm it. But I'd like it to force it to think I'm the normal user. not the org.


Solution

  • When using ssh url (like [email protected]:fakename/testapp.git), the most likely explanation is that you didn't defined a new ssh key, and used the appropriate ~/.ssh/config file in order to declare to Git what ssh key to use.

    Your ssh url would become:

    mysecondrepo:fakename/testapp.git
    

    With an ssh config file like:

    Host mysecondrepo
      HostName github.com
      User git
      IdentityFile ~/.ssh/id_rsa_mysecondrepo
    

    See "How to work on personal GitHub repo from office computer whose SSH key is already added to a work related GitHub account?" for more on multiple ssh key management.


    Of course, switching to https url (as commented by the OP) works:

     https://[email protected]/fakename/testapp.git
    

    It forces you to identify with your account.
    But it doesn't solve the ssh configuration issue.