我正在为我的项目使用 GIT。现在我想将它与 github 集成,所以我创建了一个远程:
git remote add github https://WouterJ@github.com/WouterJ/project.git
但是现在我需要填写一个密码来获取,这是我不想要的。所以我决定使用不同的 url 来获取:
git remote set-url github http://github.com/WouterJ/project.git
git remote set-url --push github https://WouterJ@github.com/WouterJ/project.git
如果我运行 git remote -v
我会得到这个:
$ git remote -v
github http://github.com/WouterJ/project.git (fetch)
github https://WouterJ@github.com/WouterJ/project.git (push)
origin http://github.com/WouterJ/project.git (fetch)
origin http://github.com/WouterJ/project.git (push)
正是我想要的,我想。但是当我进行推送时,我需要填写我的用户名。为什么?如果我直接推送到 url 如果填写它完美无缺:
git push https://WouterJ@github.com/WouterJ/project.git master
有效,但是
git push github master
不会工作
我还使用 git config
设置了不同的推送 url:
git config remote.github.pushurl https://WouterJ@github.com/WouterJ/project.git
如果我从配置中获取 pushurl,它看起来是正确的:
$ git config remote.github.pushurl
https://WouterJ@github.com/WouterJ/project.git
同时查看 .git/config 文件,看起来一切都是正确的。
我是不是漏掉了什么?这是一个错误吗?我用的是Git1.7.4,有错吗?
最佳答案
我已经找到了解决这个问题的方法,所以来回答我自己的问题:
诀窍是上传到Git1.7.8(或更高版本)。现在您使用相同的设置并且没有 _netrc
文件:
$ git push github master
Password for 'https://WouterJ@github.com/':
$ git fetch github
fetching....
所以看起来这个错误在 Git1.7.8 ( Release Notes ) 中被修复了
关于git - 远程 Pushurl 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10464250/