Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't push, git one repo, one user, two computers

I want to access my github repo from two different computers, using one github account. Everything works fine on the computer that I created the repo on. It's just this second computer that is messed up

I successfully set up a repo on github. Now I want to clone it on another machine so that I have push/pull access.

I made a public key on the second machine and specified my email as the email associated with github

ssh-keygen -t rsa -C "[email protected]",

then copied it to the SSH keys on the github website.

I cloned the repo like this

git clone https://github.com/MYUSERNAME/MYREPO

Next I edited the "url = " line in the .git/config file so that it said

url = ssh://[email protected]/MYUSERNAME/MYREPO

Both of my computers are configured to have the same user.name, USERNAME and github.user based on my github account settings. I also configured the API token with the same token on each computer.

git config --global user.name "FIRST LAST"

git config --global user.email "[email protected]"

git config --global github.user MYUSERNAME

Yet, when I try to push, this happens:

>> git push origin master

Permission denied (publickey).</code>

fatal: The remote end hung up unexpectedly
like image 336
erin Avatar asked Mar 19 '12 19:03

erin


People also ask

What happens if two people push to git at the same time?

If server detects a conflict when someone pushes data (and if two users are doing this "simultaneously" one of the pushes will be conflicting, because it will be applied only after the other one completes), the server will reject it, and the unlucky user shall then resolve conflicts and try to push again.

How do I update a GitHub repository on another computer?

First of all, clone the repo to your new system and then initialize it. Once done this change to that directory and copy or reapply the changes to the cloned repo and then add to it. $ git add . After that commit and push the changes to the remote repo.


1 Answers

The issue was a naming one, as the OP erin mentions in the comments:

I named my public key "github.pub" rather than "id_rsa.pub"

For ssh to work, using default naming convention is important.
See, for instance:

  • "git clone with ssh issue"
  • "GITHUB setup - no address associated with name"
like image 98
VonC Avatar answered Oct 06 '22 21:10

VonC