I am new to Git/GitHub and ran into an issue. I created a test project and added it to the local repository. Now I am trying to add files/project to the remote repository.
Here's what I did (and this worked) -
git remote add origin git:// Now when I try to push the repository to GitHub, using the following command, I get the following error -
git push origin master Error -
fatal: remote error: You can't push to git:// Use :my_user_name/my_repo.git 411 Answers
GitHub doesn't support pushing over the Git protocol, which is indicated by your use of the URL beginning git://. As the error message says, if you want to push, you should use either the SSH URL :my_user_name/my_repo.git or the "smart HTTP" protocol by using the https:// URL that GitHub shows you for your repository.
(Update: to my surprise, some people apparently thought that by this I was suggesting that "https" means "smart HTTP", which I wasn't. Git used to have a "dumb HTTP" protocol which didn't allow pushing before the "smart HTTP" that GitHub uses was introduced - either could be used over either http or https. The differences between the transfer protocols used by Git are explained in the link below.)
If you want to change the URL of origin, you can just do:
git remote set-url origin :my_user_name/my_repo.git or
git remote set-url origin More information is available in 10.6 Git Internals - Transfer Protocols.
12Use Mark Longair's answer, but make sure to use the HTTPS link to the repository:
git remote set-url origin You can use then git push origin master.
Mark Longair's solution using git remote set-url... is quite clear. You can also get the same behavior by directly editing this section of the .git/config file:
before:
[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git:// after:
[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = :my_user_name/my_repo.git (And conversely, the git remote set-url... invocation produces the above change.)
There is a simple solution to this for someone new to this:
Edit the configuration file in your local .git directory (config). Change git: to https: below.
[remote "origin"] url = 2I had this issue after upgrading the Git client, and suddenly my repository could not push.
I found that some old remote had the wrong value of url, even through my currently active remote had the same value for url and was working fine.
But there was also the pushurl param, so adding it for the old remote worked for me:
Before:
[remote "origin"] url = git:// fetch = +refs/heads/*:refs/remotes/origin/* pushurl = :user/repo.git NOTE: This part of file "config" was unused for ages, but the new client complained about the wrong URL:
[remote "composer"] url = git:// fetch = +refs/heads/*:refs/remotes/composer/* So I added the pushurl param to the old remote:
[remote "composer"] url = git:// fetch = +refs/heads/*:refs/remotes/composer/* pushurl = :user/repo.git This error occurs when you clone a repo using a call like:
git clone git:// This essentially sets you up as a pull-only user, who can't push up changes.
I fixed this by opening my repo's .git/config file and changing the line:
[remote "origin"] url = git:// to:
[remote "origin"] url = ssh+git://git@ This ssh+git protocol with the git user is the authentication mechanism preferred by Github.
The other answers mentioned here technically work, but they all seem to bypass ssh, requiring you to manually enter a password, which you probably don't want.
The below cmnds will fix the issue.
git pull --rebase git push If you go to you will see a textbox where you can select the git path to your repository. You'll want to use this!
I added my pubkey to github.com and this was successful:
ssh -T But I received the "You can't push" error after having wrongly done this:
git clone git:// git remote add origin :mygithubacct/dotfiles.git ...edit/add/commit git push origin master Instead of doing what I should have done:
mkdir dotfiles cd dotfiles git init git remote add origin :mygithubacct/dotfiles.git git pull origin master ...edit/add/commit git push origin master To set https globally instead of git://:
git config --global url. git:// The fastest way yuo get over it is to replace origin with the suggestion it gives.
Instead of git push origin master, use:
git push :my_user_name/my_repo.git master