2012-05-05 39 views
2

我正在使用GIT作为我的项目。现在我想将它与github上整合,所以我创建了一个远程:远程Pushurl将不起作用

git remote add github https://[email protected]/WouterJ/project.git 

但现在我需要一个密码,以填补取,东西,我不想要的。所以我决定使用不同的URL进行获取:

git remote set-url github http://github.com/WouterJ/project.git 
git remote set-url --push github https://[email protected]/WouterJ/project.git 

如果我跑git remote -v我得到这个:

$ 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) 

到底要我想要的,我想。但是当我推动我需要填写我的用户名。为什么?如果我直接推到URL如果填充它完美的作品:

git push https://[email protected]/WouterJ/project.git master 

作品,但

git push github master 

都不行


我还使用了git config设置不同的推送网址:

git config remote.github.pushurl https://[email protected]/WouterJ/project.git 

如果我从配置得到pushurl它看起来是正确的:

$ git config remote.github.pushurl 
https://[email protected]/WouterJ/project.git 

而且看的.git/config文件,它看起来像一切是正确的。


我在这里错过了什么吗?这是一个错误吗?我使用Git1.7.4,那是错的吗?

回答

2

我已经找到了如何解决这个问题,所以要aswer我自己的问题:

关键是要上传到Git1.7.8(或更高版本)。

$ git push github master 
Password for 'https://[email protected]/': 

$ git fetch github 
fetching.... 

所以它看起来像臭虫固定在Git1.7.8(Release Notes

+1

非常好。 +1。我以为你使用的是Git1.7.4(它已经高于1.7.0) – VonC

+0

等等,我输入了Git1.7.0,但是意味着Git1.7.10.1(最新的稳定版本)。谢谢,我会编辑它 –

+0

好吧,现在我明白了;)我正在做1.7.9和1.7.10的测试,但没有能够重现您的问题,以便确认它。 – VonC

1

为了推送到https GitHub地址,唯一缺失的部分是您的GitHub凭证的~/.netrc文件(或Windows上的%HOME%/_netrc文件)。请参阅“Git - How to use .netrc file on windows to save user and password”。

machine github.com 
login <login_github> 
password <password_github> 

请参阅“Syncing with github”的其他设置。

+0

感谢您的评论,但我不想:现在你使用相同的设置,并没有_netrc文件得到这个保存密码。问题是当我在'git push'命令中使用url时,我只需要键入密码。输入网址或使用遥控器'pushurl'有什么区别?我了解'pushurl'错误吗? –

+0

@WouterJ'git remote set-url --push'和'git config remote.github.pushurl'应该是等效的。是否有可能在另一个配置文件(全局或系统文件,而不是本地配置文件)中定义了github? – VonC

+0

这两种技术都不行。网址保存在正确的文件中。如果我将该url更改为本地repo,它的工作原理和url本身的工作原理,但pushurl的用户SSH部分不起作用。我也不太了解git add configs,所以全局的或系统的?你什么意思? –