git github cannot push to origin

18,857

Solution 1

The url with

git://github.com/my_username/my_repo.git

git:// Only gives read only access as mentioned in the side too..

enter image description here

Whereas,

[email protected]:my_username/my_repo.git

gives read and write access as mentioned in site

enter image description here

Though, https://github.com/my_username/my_repo.git also has read and write access but it was not working in your case because you trying to create a new remote with the same name instead of resetting it. The correct syntax as mentioned was

git remote set-url origin [email protected]:my_username/my_repo.git

And

git remote set-url origin https://github.com/my_username/my_repo.git

would also work.

Solution 2

git remote set-url origin [email protected]:my_username/my_repo.git

Share:
18,857
pahnin
Author by

pahnin

Programmer (c,cpp,javascrip,php,python) recently fell in love with ruby. I hope I'm gonna end up being rubyist.

Updated on June 21, 2022

Comments

  • pahnin
    pahnin almost 2 years

    I may be missing something, but I'm sure that I've checked everything, I forked a repo and cloned it on my system, made some changes after commiting did git push origin master

    it says

    fatal: remote error: 
      You can't push to git://github.com/my_username/my_repo.git
      Use [email protected]:my_username/my_repo.git
    

    Am I missing something? then I tried git remote add origin https://github.com/my_username/my_repo.git

    it returned

    fatal: remote origin already exists.

    I dont understand why this is hapenning, pls help

  • pahnin
    pahnin almost 12 years
    that worked and I'll accept this answer after the time limit, bt can you eplain me what the problem was? and many thnks
  • vincent mathew
    vincent mathew almost 12 years
    I think https url is only for read only repository fetching. But git@github also gives write and read access.