git - 远程 Pushurl 不起作用

标签 git github git-remote

我正在为我的项目使用 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/

相关文章:

git - 将项目上传到现有项目

github - 如何为来自同一个 ssh 客户端的两个单独的 GitHub 帐户设置身份验证?

GitHub 上的 README.md 中未显示图像

security - GPG 与 SSH key

git - 我将 SourceTree 与 Git 结合使用,但需要使用 SVN 存储库,我有哪些选项?

git - 将补丁集从 Gerrit pull 入当前分支

bash - git bash 立即关闭

远程分支中特定文件行的下一次更改的 Git 日志

git - 为什么不应该将 ssh 和智能 http 访问与 git 混合使用?

git - 如何在不使用 jgit checkout 的情况下在远程存储库中创建 git 分支