git SourceTree 不断询问 Github 密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38489022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SourceTree keeps asking for Github password
提问by Abigail Fox
My organization is switching from Bitbucket to Github for project management. Today, I was trying to transfer our most recent project from Bitbucket to Github, by using SourceTree. I added a second remote repository to the project (using the URL of the destination repository on Github), brought everything up to date, and then attempted to push the code to the repository. A box popped up, asking for the password to my Github account. I entered in my (correct) password, and clicked 'OK', and the dialog box popped up again. I entered in my password (correctly) again, and it did the same thing.
我的组织正在从 Bitbucket 切换到 Github 进行项目管理。今天,我试图通过使用 SourceTree 将我们最近的项目从 Bitbucket 转移到 Github。我向项目添加了第二个远程存储库(使用 Github 上目标存储库的 URL),将所有内容更新,然后尝试将代码推送到存储库。弹出一个框,要求输入我的 Github 帐户的密码。我输入了我的(正确的)密码,然后单击“确定”,然后再次弹出对话框。我再次(正确)输入了我的密码,它做了同样的事情。
My username is correctly identified, my password is correct, and I tried updating SourceTree because I had heard that it was an issue with a previous version. The problem persists.
我的用户名被正确识别,我的密码正确,我尝试更新 SourceTree,因为我听说这是以前版本的问题。问题仍然存在。
I am using SourceTree 2.3.1
我正在使用 SourceTree 2.3.1
回答by Chris
If you are using two-factor authentication with GitHub you will need to create a personal access token and use it with SourceTree:
如果您在 GitHub 上使用双因素身份验证,则需要创建个人访问令牌并将其与 SourceTree 一起使用:
To work with GitHub's two-factor authentication in SourceTree you can simply use your access token instead of your password. The steps to do this are as follows:
- Go to your Personal Access Tokenssettings in GitHub.
- Click on the Generate new tokenbutton.
- Name the token something descriptive.
- Select which scopes you wish to grant this token.
- Click the Generate tokenbutton.
- Copy the token and use it as a password in your hosted repositories.
You can find more information about this on GitHub's help here.
要在 SourceTree 中使用 GitHub 的双因素身份验证,您只需使用访问令牌而不是密码即可。执行此操作的步骤如下:
- 转到GitHub 中的个人访问令牌设置。
- 单击生成新令牌按钮。
- 将令牌命名为描述性的名称。
- 选择您希望授予此令牌的范围。
- 单击生成令牌按钮。
- 复制令牌并将其用作托管存储库中的密码。
您可以在此处的 GitHub 帮助中找到有关此的更多信息。
Mac Users:If your SourceTree keeps on asking for the password, go to the Terminal and type this:
Mac 用户:如果您的 SourceTree 一直要求输入密码,请转到终端并输入以下内容:
git config --global credential.helper osxkeychain
回答by AEQ
I had a similar thing after an update; I tried re-adding my bitbucket credentials, changing the protocols, etc. with no luck, until...
更新后我有类似的事情;我尝试重新添加我的 bitbucket 凭据,更改协议等,但没有运气,直到...
I opened my keychain and searched for bitbucket (probably the same for github, just search for github instead) under the Passwords category.
I found that I had multiple Access Keys for my user, so I closed my repository, deleted all the keys of "application password" Kind, opened the SourceTree preferences > Accounts > removed my account and re-added it (login as usual - I used Basic with HTTPS).
Keychain asks for permission to save the password, which I said yes and now I only see one key of the kind "application password".
我打开我的钥匙串并在密码类别下搜索 bitbucket(可能与 github 相同,只需搜索 github)。
我发现我的用户有多个访问密钥,所以我关闭了我的存储库,删除了“应用程序密码”种类的所有键,打开了 SourceTree 首选项 > 帐户 > 删除了我的帐户并重新添加了它(照常登录 - 我使用带有 HTTPS 的 Basic)。
钥匙串要求获得保存密码的许可,我说是的,现在我只看到一个“应用程序密码”类型的钥匙。
I opened my repository from the repo browser and hey presto, no more password popups!
我从 repo 浏览器打开了我的存储库,嘿,快了,没有更多的密码弹出窗口!
This bugged me for a whole week! If this helped you, you can do a little dance with me now :)
这让我困扰了整整一周!如果这对你有帮助,你现在可以和我一起跳舞了 :)
回答by Prabhu.Somasundaram
open terminal and clone your repo. repository url must have your usedid, For ex:
打开终端并克隆您的存储库。存储库 url 必须有您的 usedid,例如:
$ git clone https://<username>@github.com/<userId>/<reponame>.git
$ git clone https://[email protected]/mak123/<reponame>.git
Then drag and drop the cloned folder into the sourceTree window.You can also do by clicking "+New Repository" button and from the menu by selecting "Add Existing Local Repository". It may ask for password again but this time it will get added to your keychain.
然后将克隆的文件夹拖放到 sourceTree 窗口中。您也可以通过单击“+New Repository”按钮并从菜单中选择“Add Existing Local Repository”来完成。它可能会再次要求输入密码,但这次它会被添加到您的钥匙串中。
回答by A_01
A solution worked for me given by Andrew Magill, Copied from Source : link
安德鲁·马吉尔 (Andrew Magill) 提供的对我有用的解决方案,从来源复制:链接
The problem is that SourceTree's embedded Git client comes with git-credential-manager v1.12, which no longer works with Github since they disabled TLS 1.1 on their site. You need to get git-credential-manager v1.14. Easiest way to do that is to install a current copy of the Git client separately, and then switch SourceTree over to use that ("system git") instead of its embedded client. Alternatively, you can update git-credential-manager in your embedded client by replacing its files with the newest version from Microsoft.
问题是 SourceTree 的嵌入式 Git 客户端带有 git-credential-manager v1.12,由于他们在其站点上禁用了 TLS 1.1,因此不再与 Github 一起使用。您需要获得 git-credential-manager v1.14。最简单的方法是单独安装 Git 客户端的当前副本,然后切换 SourceTree 以使用它(“系统 git”)而不是其嵌入式客户端。或者,您可以通过使用 Microsoft 的最新版本替换其文件来更新嵌入式客户端中的 git-credential-manager。
回答by Marc
I am using a SSH key, but SourceTree was asking me a password every time.
我正在使用 SSH 密钥,但 SourceTree 每次都问我密码。
Found on the community of Atlassian, this solution worked for me:
在 Atlassian 社区上找到的这个解决方案对我有用:
- Open the terminal, get into your project directory
- Type
git config credential.helper store
- Type
git pull
- Input username/password (if asked)
- 打开终端,进入你的项目目录
- 类型
git config credential.helper store
- 类型
git pull
- 输入用户名/密码(如果询问)
Voilà !
瞧!
回答by bcr
In addition to setting up the Personal Access Token on GitHub, and doing what A_01 states above, this may be helpful (it's how I finally got it working)
除了在 GitHub 上设置个人访问令牌并执行上述 A_01 所述之外,这可能会有所帮助(这就是我最终让它工作的方式)
- I made sure had the latest version of Sourcetree
- I upgraded to the latest version of and used System Git (Tools -> Options -> Git)
- Upgraded to the latest Git Credential Manager for Windows (this was via an installer I downloaded and double-clicked, very easy)
- Ensured I was using OAuth for my GitHub account stored in Tools -> Options -> Authentication
- Made sure I checked off the box "Allow Sourcetree to manage my credentials using the Git Credential Manager" (this was important!!) on Tools -> Options -> Git
- Then when I triggered the GitHub dialog (via pushing a new branch, just an example), I logged in there (this is where it used to fail).
- I next got the 2 factor auth dialog, and the code was sent to my phone as expected. I was able to enter the code from my phone into this dialog.
- 我确定有最新版本的 Sourcetree
- 我升级到最新版本并使用了 System Git(工具 -> 选项 -> Git)
- 升级到适用于 Windows 的最新 Git Credential Manager(这是通过我下载并双击的安装程序,非常简单)
- 确保我对存储在工具 -> 选项 -> 身份验证中的 GitHub 帐户使用 OAuth
- 确保我在工具 -> 选项 -> Git 上勾选了“允许 Sourcetree 使用 Git 凭据管理器管理我的凭据”(这很重要!!)
- 然后当我触发 GitHub 对话框时(通过推送一个新分支,只是一个例子),我登录那里(这是它曾经失败的地方)。
- 我接下来得到了 2 因素身份验证对话框,并且代码按预期发送到我的手机。我能够将手机中的代码输入到此对话框中。
回答by Josh
SourceTree version 2.4.8.0
SourceTree 版本 2.4.8.0
The problem for me seemed to be the order of setup between SourceTree and GitHub. I setup SourceTree first and just clicked all the "setup later" options.
我的问题似乎是 SourceTree 和 GitHub 之间的设置顺序。我首先设置 SourceTree,然后单击所有“稍后设置”选项。
An easy fix - Uninstall and re-install SourceTree. The non-obvious bit was needing to delete the actual program files manually.
一个简单的修复 - 卸载并重新安装 SourceTree。不明显的一点是需要手动删除实际的程序文件。
From any "SourceTree.exe" shortcut, open file location. Mine forked at "C:\Users\myusername\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Atlassian" where the shortcut pointed to another shortcut.
从任何“SourceTree.exe”快捷方式,打开文件位置。我的分支在“C:\Users\myusername\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Atlassian”,其中快捷方式指向另一个快捷方式。
Open that shortcut's file location. I eventually ended up at "C:\Users\myusername\AppData\Local\SourceTree". Delete the whole "SourceTree" folder. Go up one level to "...\Local" and delete the "Atlassian" folder as well.
打开该快捷方式的文件位置。我最终在“C:\Users\myusername\AppData\Local\SourceTree”结束。删除整个“SourceTree”文件夹。上一级到“...\Local”并删除“Atlassian”文件夹。
Now uninstall SourceTree. Make sure your GitHub is setup the way you desire (for me, I also created and saved an SSH key that I used for SourceTree setup). Re-install SourceTree using all the correct credentials, point to the right repository and such.
现在卸载 SourceTree。确保你的 GitHub 按照你想要的方式设置(对我来说,我还创建并保存了一个用于 SourceTree 设置的 SSH 密钥)。使用所有正确的凭据重新安装 SourceTree,指向正确的存储库等。
After all this, SourceTree asked for my GitHub credentials twice, with two different dialog boxes, then stopped and worked! No more endless loop. Good luck!
做完这一切之后,SourceTree 两次询问我的 GitHub 凭据,使用两个不同的对话框,然后停止并开始工作!没有更多的无限循环。祝你好运!
回答by ifeegoo
If you are using "Username & Password" authentication,you can try to change to use SSH keysfor the authentication.
如果您使用“用户名和密码”身份验证,您可以尝试更改为使用SSH 密钥进行身份验证。
I have met this kind of situation when I commit to GitLab everytime.When I changed the way of authentication:SSH keys,the problem has been solved.
每次提交GitLab时都遇到过这种情况,当我改变认证方式:SSH keys后,问题就解决了。
回答by Jboy Flaga
This is what I discovered (after searching for 'sourcetree' in my drive C:):
这是我发现的(在我的驱动器 C: 中搜索“sourcetree”之后):
- Uninstall SourceTree
- Delete folder C:\Users[username]\AppData\Local\Atlassian\SourceTree
- Delete folder C:\Users[username]\AppData\Local\SourceTree
- Reinstall SourceTree
- 卸载 SourceTree
- 删除文件夹 C:\Users[用户名]\AppData\Local\Atlassian\SourceTree
- 删除文件夹 C:\Users[用户名]\AppData\Local\SourceTree
- 重新安装 SourceTree
回答by VonC
If you are not using GitHub 2FA, another reason for asking you your password is:
如果您没有使用GitHub 2FA,询问您密码的另一个原因是:
Your GitHub repo url is an ssh one, not an https one.
Since git does not find your ssh keys (or your ssh key is not registered to your GitHub account), it fails back to account/password mechanism.
您的 GitHub 存储库网址是 ssh 网址,而不是 https 网址。
由于 git 找不到您的 ssh 密钥(或者您的 ssh 密钥未注册到您的 GitHub 帐户),因此它无法返回到帐户/密码机制。
If you are using 2FA (and an https url), then you need a personal token as a password.
如果您使用 2FA(和 https url),那么您需要一个个人令牌作为密码。