我有多个我正在贡献的存储库 - 一些存放在Github上,一些存放在Assembla上。从技术上讲,我的用户名在两个系统之间有所不同。
当我cd
到给定存储库的内容时,我需要知道以下内容:
git config user.name
做了这个,不是 git config --global user.name
)我发现git config --get user.name
会产生正确的信息,但当我尝试提取或提交时,系统会提示我输入用户名:
Username for 'https://github.com'
如何确保我的身份正确链接到两个git世界? 我意识到#1与SSH密钥无关,但提交,虽然它是我的设置的一部分,所以我将它包含在这里以供我参考我想要完成的内容。
答案 0 :(得分:2)
首先,user.name,user.email的配置值与服务器的身份验证无关(允许你推送,获取等等),这些仅用于填写提交消息和作者信息
有人认为你可以做的是创建一个ssh密钥对,并为assembla和github使用相同的公钥。然后,当从github克隆存储库时,请确保使用SSH协议
git@github.com:username/repositoryname.git
而不是
https://github.com/username/repositoryname
(组合相同)
如果你正确配置,你就不会被要求输入用户名或密码
注意:git@github.com:username / repositoryname.git是ssh://git@github.com的简写:username / repositoryname.git含义相同
注2:关于git-scm的书解释了SSH协议(以及其他):http://git-scm.com/book/en/Git-on-the-Server-The-Protocols,github总是使用" git" username并使用ssh密钥识别github用户