ddi*_*ppa 173 git github visual-studio visual-studio-code
我开始使用Visual Studio Code,我试图将我的测试项目保存到GitHub,但Visual Studio Code总是要求我的GitHub凭据.
我已经安装在我的PC GitHub Desktop和Git中,我已经运行:
git config --global credential.helper wincred
Run Code Online (Sandbox Code Playgroud)
但仍然Visual Studio Code要求提供凭据.
有帮助吗?
这是我的.gitconfig文件,位于用户配置文件中:
[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
required = true
[user]
name = ddieppa
[user]
email = fake@live.com
[credential]
helper = wincred
Run Code Online (Sandbox Code Playgroud)
以下是要求凭据的弹出窗口:
我在弹出窗口中输入了我的GitHub凭据,但仍然在Visual Studio代码的Git输出窗口中出现此错误:
remote: Anonymous access to ddieppa/LineOfBizApp.git denied.
fatal: Authentication failed for 'https://github.com/ddieppa/LineOfBizApp.git/'
Run Code Online (Sandbox Code Playgroud)
Dav*_*vuz 131
我在VSCode文档上找到了解决方案:
提示:您应该设置一个凭据帮助程序,以避免每次VS代码与您的Git远程控制器对话时都要求提供凭据.如果不这样做,您可能需要考虑在...菜单中禁用自动提取以减少您获得的提示数量.
因此,打开凭证助手,以便Git将密码保存在内存中一段时间.默认情况下,Git会将您的密码缓存15分钟.
在终端中,输入以下内容:
git config --global credential.helper cache
# Set git to use the credential memory cache
Run Code Online (Sandbox Code Playgroud)
要更改默认密码缓存超时,请输入以下内容:
git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
Run Code Online (Sandbox Code Playgroud)
我在上面安装了VS Code并配置相同,但正如@ddieppa所说,它对我来说也不起作用.所以我试着在用户设置中找到一个选项,我看到"git.autofetch"= true,现在设置它是假的!VS Code不再需要重复输入密码!
在菜单中,单击文件/首选项/用户设置并键入以下内容:
将您的设置放在此文件中以覆盖默认设置
{
"git.autofetch": false
}
Run Code Online (Sandbox Code Playgroud)
yoh*_*uff 59
您应该能够像这样设置您的凭据:
git remote set-url origin https://<USERNAME>:<PASSWORD>@bitbucket.org/path/to/repo.git
您可以像这样获取远程URL:
git config --get remote.origin.url
Vai*_*hal 35
这对我
有用:1.将凭证hepler设置为存储
$ git config --global credential.helper store
2.然后验证是否需要:
$ git config --global credential.helper
store
使用从Here引用的git bash的简单示例(仅适用于当前repo,--global
用于所有repos)
$ git config credential.helper store
$ git push http://example.com/repo.git
Username: < type your username >
Password: < type your password >
[几天后]
$ git push http://example.com/repo.git
[您的凭据自动使用]
也适用于VS Code.
更详细的例子和先进的使用在这里.
注意:用户名和密码未加密并以纯文本格式存储,因此仅在个人计算机上使用.
Ada*_*son 24
通常,您可以使用内置的凭证存储设施:
git config --global credential.helper store
或者,如果您使用的是 Windows,则可以使用他们的凭证系统:
git config --global credential.helper wincred
或者,如果您使用的是 MacOS,则可以使用他们的凭证系统:
git config --global credential.helper osxkeychain
在大多数情况下,第一种解决方案是最佳的。
Red*_*dog 19
尝试安装" Git Credential Manager For Windows "(以及设置凭据管理器的说明).
当在使用Git的应用程序中需要时(例如VS代码),它将" 神奇地 "打开Visual Studio Team Services凭据输入所需的对话框.
GoT*_*oTo 17
我所要做的就是运行这个命令:
git config --global credential.helper wincred
然后我被提示输入密码两次.
下次它工作而没有提示我输入密码.
Cod*_*ard 15
使用ssh而不是http/https.
您需要在本地计算机上设置ssh密钥,将它们上传到您的git服务器并将url表单替换http://
为git://
,您将不再需要使用密码.
如果你不能使用ssh将其添加到你的配置:
[credential "https://example.com"]
username = me
Run Code Online (Sandbox Code Playgroud)
文件在这里.
只需按照这些步骤操作即可立即设置您的ssh密钥:
生成新的ssh密钥(如果已有密钥,则跳过此步骤)
ssh-keygen -t rsa -C "your@email"
将密钥集放在home/.ssh
目录(或Users/<your user>.ssh
Windows下)后,打开它并复制内容
SSH keys
Add ssh key
你们都准备去了:-)
小智 12
以下步骤指导您完成以下操作:
**如果您的工作特别敏感,则生成没有密码短语的SSH密钥是不明智的。
操作系统 -Fedora 28 | 编辑器 -VS Code v1.23.0 |仓库 -Git
生成SSH密钥:
ssh-keygen -t rsa -C "email@goeshere.com"
完成上述步骤后,公共密钥的位置将显示在终端窗口中。如果当前登录的用户为“ bob”,则您的公共密钥的位置为 /home/bob/.ssh/id_rsa.pub
复制公钥并将其导入GitHub:
cat /home/bob/.ssh/id_rsa.pub
将现在显示在终端窗口中的整个公钥复制到剪贴板
确认以上步骤:
ssh -T git@github.com
yes
嗨!您已成功通过身份验证,但是GitHub不提供Shell访问。
首次提交/推送而无需输入用户名/密码:
-touch test.txt
git add test.txt
git commit
-打开编辑器,输入消息并保存文件。如果vi是您的编辑器,则i
在打开文件后按,输入消息,按esc,然后按Enter :x
保存更改。
git push
您可能遇到的唯一麻烦是,当您尝试SSH到GitHub时。此链接将提供一些帮助-
狩猎愉快!
Mar*_*ark 10
自动 Git 身份验证。从 v1.45发行说明:
GitHub 存储库的 GitHub 身份验证
VS Code 现在具有针对 GitHub 存储库的自动 GitHub 身份验证。您现在可以在公共和私有存储库之间进行克隆、拉取、推送,而无需在系统中配置任何凭证管理器。即使是在集成终端中调用的 Git 命令,例如 git push,现在也会根据您的 GitHub 帐户自动进行身份验证。
您可以使用
git.githubAuthentication
设置禁用 GitHub 身份验证 。您还可以通过设置禁用终端身份验证集成git.terminalAuthentication
。
小智 6
我在 Visual Studio Code 和Ubuntu\xc2\xa020.04 (Focal Fossa) 上运行了这个:
\n它自动解决了经常询问凭据的问题:
\ngit config --global credential.helper store\n
Run Code Online (Sandbox Code Playgroud)\n
小智 5
Ubuntu 用户只需在 Visual Studio Code 的终端中输入以下命令:
git config --global credential.helper store
Run Code Online (Sandbox Code Playgroud)
现在,输入一次您的用户名和密码,之后就不会再询问您了。
笔记:
用户名和密码未加密并以纯文本格式存储,因此请谨慎使用。
但是,如果您的密码包含一些特殊字符,如@、#、&、*等,那么这些字符将被加密。
此外,您还可以在家中找到“.git-credentials”文件。它是隐藏的,因此请确保启用隐藏文件。
位置:~/.git-credentials
归档时间: |
|
查看次数: |
153925 次 |
最近记录: |