Git跳过用户名提示

Git跳过用户名提示,git,Git,当user.name不起作用时,我在配置中设置了user.name和user.email,但每次从远程推/拉时仍会提示我输入用户名 $ git config user.name 'myemail@example.com' $ git config user.email 'myemail@example.com' $ git pull Username for 'https://example.com': 我怎么能跳过这个提示 我仍然希望每次都必须输入密码。您缺少将其保存在全局git配置中的-

user.name
不起作用时,我在配置中设置了
user.name
user.email
,但每次从远程推/拉时仍会提示我输入用户名

$ git config user.name 'myemail@example.com'
$ git config user.email 'myemail@example.com'
$ git pull
Username for 'https://example.com': 
我怎么能跳过这个提示


我仍然希望每次都必须输入密码。

您缺少将其保存在全局git配置中的
--global
标志。要同时为
git push
缓存用户名,请参见您缺少
--global
标志,以将其保存在全局git配置中。要同时缓存您的用户名以进行
git push
,请参见
user.name
user.email
与身份验证无关。它们表示应该存储在提交中的值;也就是说,您的姓名和电子邮件地址存储在“作者”和“提交者”字段中,并在
git log
中查看

user.name
应为您的个人姓名;也就是说,其他人称呼你们的某种形式的名字


对于身份验证,您可以在URL中使用用户名,例如
https://myemail%40example.com@example.com/owner/repo.git
,或者您可以运行
git-config-credential。https://example.com/.username myemail@example.com
。请注意,如果在URL中输入值,则需要对所有相关字符进行百分比编码,正如我所演示的。

user.name
user.email
与身份验证无关。它们表示应该存储在提交中的值;也就是说,您的姓名和电子邮件地址存储在“作者”和“提交者”字段中,并在
git log
中查看

user.name
应为您的个人姓名;也就是说,其他人称呼你们的某种形式的名字

对于身份验证,您可以在URL中使用用户名,例如
https://myemail%40example.com@example.com/owner/repo.git
,或者您可以运行
git-config-credential。https://example.com/.username myemail@example.com
。请注意,如果将该值放入URL,则需要对任何相关字符进行百分比编码,正如我所演示的。

您可以使用

git config --global credential.helper store
有关更多信息和设置,请检查此链接: 您可以使用

git config --global credential.helper store
有关更多信息和设置,请检查此链接:

我很确定它也会存储密码,OP说他们不需要。你是对的:)我很确定它也会存储密码,OP说他们不需要。你是对的:)如果git存储库位于
https://example.com/path/to/repo.git
,我是否在配置中指定了整个URL?您将编辑
.git/config
,以调整存储库URL以包括前面提到的
username@
部分。我的意思是,配置是否存储每个域或每个存储库的用户名。您的示例命令是:
git-config-credential。https://example.com/.username myemail@example.com
,但应该是
git-config-credential。https://example.com/path/to/repo.git.username myemail@example.com
用于远程at
https://example.com/path/to/repo.git
?除非你有充分的理由,仅使用URL中带有主机名的部分,尽管两者都可以接受。有关更多详细信息,请参阅
gitcredential(7)
。如果git存储库位于
https://example.com/path/to/repo.git
,我是否在配置中指定整个URL您将编辑
.git/config
,以调整存储库URL以包括前面提到的
username@
部分。我的意思是,配置是否存储每个域或每个存储库的用户名。您的示例命令是:
git-config-credential。https://example.com/.username myemail@example.com
,但应该是
git-config-credential。https://example.com/path/to/repo.git.username myemail@example.com
用于远程at
https://example.com/path/to/repo.git
?除非你有充分的理由,仅使用URL中带有主机名的部分,尽管两者都可以接受。有关更多详细信息,请参见
gitcdential(7)
。为什么推荐url方法?@Ben您对该问题的回答与bk2204对该问题的回答相同。一旦我确认,我可能会接受bk2204的回答。在我发布我的问题之前,我在搜索答案时没有找到那个问题,它是同一个问题。不幸的是,关于它的大多数答案对我来说都没有用处。“不过,它可能仍然算是重复的。@本,你对那个问题的回答与bk2204对这个问题的回答相同。一旦我确认,我可能会接受bk2204的回答。在我发布我的问题之前,我在搜索答案时没有找到那个问题,它是同一个问题。不幸的是,关于它的大多数答案对我来说都没有用处。不过,它可能仍然算是一个复制品。