Reputation: 41934
I'm using GIT for my projects. Now I want to integrate it with github, so I created a remote:
git remote add github https://[email protected]/WouterJ/project.git
But now I need to fill in a password for fetching, something that I don't want. So I decided to use a different url for fetching:
git remote set-url github http://github.com/WouterJ/project.git
git remote set-url --push github https://[email protected]/WouterJ/project.git
If I run git remote -v
I get this:
$ git remote -v
github http://github.com/WouterJ/project.git (fetch)
github https://[email protected]/WouterJ/project.git (push)
origin http://github.com/WouterJ/project.git (fetch)
origin http://github.com/WouterJ/project.git (push)
Exactly want I want, I thought. But when I do a push I need to fill in my Username. Why? If I push directly to the url if filled in it works perfectly:
git push https://[email protected]/WouterJ/project.git master
Works, but
git push github master
Won't work
I also used the git config
to set a different push url:
git config remote.github.pushurl https://[email protected]/WouterJ/project.git
And if I get the pushurl from the config it looks like it is correct:
$ git config remote.github.pushurl
https://[email protected]/WouterJ/project.git
Also looking at the .git/config file it looks like everything is correct.
Am I missing something here? Is it a bug? I use Git1.7.4, is that wrong?
Upvotes: 3
Views: 902
Reputation: 41934
I have found how you can solve this, so to aswer my own question:
The trick is to upload to Git1.7.8 (or higher). Now you get this with the same settings and without a _netrc
file:
$ git push github master
Password for 'https://[email protected]/':
$ git fetch github
fetching....
So it looks like the bug is fixed in Git1.7.8 (Release Notes)
Upvotes: 2
Reputation: 1323953
The only missing piece, in order to push to an https GitHub address, is your ~/.netrc
file (or %HOME%/_netrc
file on Windows) with your GitHub credentials in it.
See "Git - How to use .netrc
file on windows to save user and password".
machine github.com
login <login_github>
password <password_github>
See other settings at "Syncing with github".
Upvotes: 1