Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git github cannot push to origin

Tags:

git

github

push

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

like image 438
pahnin Avatar asked Jun 19 '12 12:06

pahnin


People also ask

Why is git push origin not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

How do I fix failed to push some refs to Origin?

To fix this issue, run git pull on your local repository. This should allow you to push to origin again.

Why can't I push code to GitHub?

To push a branch on remote, your branch needs to have the latest changes present in remote repository. If you get the failed to push error, first do git pull the branch to get the latest commits and then push it.


1 Answers

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.

like image 76
vincent mathew Avatar answered Oct 12 '22 16:10

vincent mathew