简体   繁体   English

SourceTree - git:致命:远程错误:找不到存储库

[英]SourceTree - git: fatal: remote error: Repository not found

I just signed up for a github account at work and created a new repository.我刚刚在工作中注册了一个 github 帐户并创建了一个新的存储库。 I ran a few git commands over command line and everything worked fine.我通过命令行运行了一些 git 命令,一切正常。

1. git init 
2. git add .
3. git commit -m "first commit"
4. git remote add origin https://github.com/username/project.git

Then, when I added the working copy from sourcetree and clicked the Fetch button, i get "error: Repository Not Found".然后,当我从 sourcetree 添加工作副本并单击 Fetch 按钮时,我得到“错误:未找到存储库”。 I try push and pull and i get the same error.我尝试推拉,我得到同样的错误。 I've been using sourcetree with my bitbucket and github repositories for a few months now but i've never had this problem.几个月来,我一直在将 sourcetree 与 bitbucket 和 github 存储库一起使用,但我从来没有遇到过这个问题。 Has anyone had similar issues?有没有人有类似的问题?

Had the same issue.有同样的问题。 The reason in my case was that I authenticated via https on command line but then used sourceTree via oAuth.就我而言,原因是我在命令行上通过 https 进行了身份验证,然后通过 oAuth 使用了 sourceTree。 Setting the Auth type to "Basic" in my Account settings helped.在我的帐户设置中将身份验证类型设置为“基本”有帮助。

I figured it out the issue.我想通了这个问题。 I already had aa personal github account linked to sourcetree.我已经有一个链接到 sourcetree 的个人 github 帐户。 When i deleted the personal github account and added the work account it worked fine.当我删除个人 github 帐户并添加工作帐户时,它运行良好。

  1. Go to Tools -> Options转到工具 -> 选项
  2. Click on Authentication Tab单击身份验证选项卡
  3. Delete the other github account and add the new one删除另一个 github 帐户并添加新的

I have experienced the problem on Windows (8.1 x64) with a more subtle reason.我在 Windows (8.1 x64) 上遇到过这个问题,原因更微妙。 The problem stemmed from the use of git authentication hooks, like the git-credential-winstore ( https://gitcredentialstore.codeplex.com/ ).问题源于使用 git 身份验证挂钩,例如 git-credential-winstore ( https://gitcredentialstore.codeplex.com/ )。

In order for it to work i simply removed my network password to github like this:为了让它工作,我简单地将我的网络密码删除到 github,如下所示:

  1. Start menu开始菜单
  2. Manage Network Passwords管理网络密码
  3. Removed my password for http://github.com删除了我的http://github.com密码

If you want to entirely remove the git credential store this SO post which may be of help: https://stackoverflow.com/a/18376438如果您想完全删除 git 凭证存储此 SO 帖子,这可能会有所帮助: https : //stackoverflow.com/a/18376438

Simple solution for me was that because the repo was a private repo .对我来说简单的解决方案是因为 repo 是一个private repo I had to append my username and an at-symbol ( @ ) before the git URL.我必须在 git URL 之前附加我的用户名和 at 符号 ( @ )。

Set your remote to将您的遥控器设置为

https://YOUR_USER_NAME@github.com/YOUR_COMPANY_NAME/YOUR_REPO_NAME.git

instead of代替

https://github.com/YOUR_COMPANY_NAME/YOUR_REPO_NAME.git

Then enter your github user password upon eventual request.然后根据最终要求输入您的 github 用户密码。

Or rather use SSH instead或者更确切地说使用 SSH

ssh://git@github.com/YOUR_COMPANY_NAME/YOUR_REPO_NAME.git

as HTTPS is to be deprecated soon.因为 HTTPS 即将被弃用。

I just had to set the current Account I wanted to use as SET TO DEFAULT on the path Tools/ Authentication Tab我只需要在路径工具/身份验证选项卡上设置我想使用的当前帐户作为 SET TO DEFAULT

I was having the same Repository not found我找不到相同的存储库

Error错误

In my case, it was because I was using HTTPS in stead of SSH as the remote repository path in SourceTree (Settings > Remotes).就我而言,这是因为我使用 HTTPS 而不是 SSH 作为 SourceTree 中的远程存储库路径(设置 > 远程)。

Didn't work in Sourcetree: https://github.com/companyname/reponame.git在 Sourcetree 中不起作用: https://github.com/companyname/reponame.git : https://github.com/companyname/reponame.git

Worked in Sourcetree: git@github.com:companyname/reponame.git曾在 Sourcetree 工作: git@github.com:companyname/reponame.git

To get the latter from GitHub, click Clone or download then Use SSH要从 GitHub 获取后者,请单击Clone or download然后Use SSH

In my case i did the following steps:就我而言,我执行了以下步骤:

  1. Sourcetree > Preferences Sourcetree > 首选项
  2. Advanced先进的
  3. Remove all usernames in the list删除列表中的所有用户名
  4. Restart Sourcetree重启源码树

I've had this a few times when it seems the Personal Access Token expires.当个人访问令牌似乎过期时,我已经遇到过几次。

Regenerated the token in github (Your Profile -> Settings -> Security then find a link saying Personal Access Tokens) (don't forget to tick the appropriate boxes to grant permissions).在 github 中重新生成令牌(您的个人资料 -> 设置 -> 安全性,然后找到一个说个人访问令牌的链接)(不要忘记勾选适当的框以授予权限)。

Then in SourceTree Tools -> Options -> Authentication and delete the accounts as others have said.然后在 SourceTree Tools -> Options -> Authentication 并删除其他人所说的帐户。 Next time you try it you get a github username+password prompt.下次尝试时,您会收到 github 用户名+密码提示。 (Enter username and personal access token as the password.) (输入用户名和个人访问令牌作为密码。)

Issue: I was trying to access the organisation's app using SourceTree.问题:我试图使用 SourceTree 访问组织的应用程序。 But a permission from organisation is needed.但是需要得到组织的许可。

The solution: I've installed GitHub Desktop application https://desktop.github.com/ Authorized with needed account.解决方案:我已经安装了 GitHub Desktop 应用程序https://desktop.github.com/使用所需帐户授权。 It generated an additional SSH key (There were ssh keys for my account there already, and from terminal pull/push worked, but still GitHub Desktop added an additional one).它生成了一个额外的 SSH 密钥(那里已经有我的帐户的 ssh 密钥,并且从终端 pull/push 工作,但 GitHub Desktop 仍然添加了一个额外的密钥)。 And SourceTree started to display the needed private repository, started to push and pull as needed.并且 SourceTree 开始显示需要的私有仓库,开始按需推送和拉取。

I had a working git project for several months in source tree and this suddenly happened one day.我在源代码树中有几个月的工作 git 项目,这突然发生在某一天。 I tried to check everything related to authentication and found this fix:我尝试检查与身份验证相关的所有内容并找到了此修复程序:

On the project window, right click your project, click "Convert to SSH".在项目窗口中,右键单击您的项目,单击“转换为 SSH”。 I might have accidentally set it to "Convert to HTML" which caused the "Repository not found error".我可能不小心将它设置为“转换为 HTML”,这导致了“未找到存储库错误”。

Hope this helps guys that have a working setup, working accounts, working ssh authentications, and yet suddenly encounters this error.希望这可以帮助那些拥有有效设置、有效帐户、有效 ssh 身份验证但突然遇到此错误的人。

For me the issue seemed to be how the repo was cloned.对我来说,问题似乎是如何克隆回购。 I had a repo cloned by HTTPS and even though I had a valid SSH key + account (using oauth) it kept erroring out.我有一个通过 HTTPS 克隆的 repo,即使我有一个有效的 SSH 密钥 + 帐户(使用 oauth),它也一直出错。

What I did to fix it was in the repo browser for SourceTree, I right clicked the repo and I selected "Convert to SSH".我在SourceTree的repo浏览器中修复了它,我右键单击了repo并选择了“转换为SSH”。

After that it worked.在那之后它起作用了。

I run into the similar problem and it turns out it is because ssh authentication.我遇到了类似的问题,结果证明是因为 ssh 身份验证。

The server is bitbucket (instead of git.com).服务器是 bitbucket(而不是 git.com)。

So for that, Bitbucket needs users to establish identification before pushing commits (even though it doesn't request authentication while pulling it into local machines).因此,为此,Bitbucket 需要用户在推送提交之前建立标识(即使它在将其拉入本地机器时不请求身份验证)。 The solution is to : step1: create keys in your local machine.解决方法是: step1:在本地机器上创建密钥。 $ssh-keygen -t rsa step2: copy the public key to the Bitbucket $cat ~/.ssh/id_rsa.pub copy the key to profile->account->SSH keys->Add key $ssh-keygen -t rsa step2:将公钥复制到Bitbucket $cat ~/.ssh/id_rsa.pub 将密钥复制到profile->account->SSH keys->Add key

In November 2020 GitHub has changed how users authenticate when using Git for Windows, and now requires the use of a web browser to authenticate to GitHub. 2020 年 11 月,GitHub 更改了用户在使用 Git for Windows 时进行身份验证的方式,现在要求使用 Web 浏览器对 GitHub 进行身份验证。 I updated Git for Windows to version 2.29.2.3 and solved the problem.我将 Git for Windows 更新到版本 2.29.2.3 并解决了问题。

  1. Check if you are using proper public key at github.com .检查您是否在github.com上使用了正确的公钥。 Go to Settings –> SSH and PGP keys section and add your public key if it is not present there.转到“设置”->“SSH 和 PGP 密钥”部分,如果那里不存在,请添加您的公钥。

  2. Go to Terminal and use ssh -vT git@github.com command to check if all is fine and you are using same key for authorisation.转到终端并使用ssh -vT git@github.com命令检查是否一切正常,并且您是否使用相同的密钥进行授权。 If not, add proper key to Github account (id_ed25519 for example).如果没有,请为 Github 帐户添加正确的密钥(例如 id_ed25519)。

  3. Use SSH authentification in Sourcetree for your repository, if not – convert it to SSH.Sourcetree 中为您的存储库使用 SSH 身份验证,如果没有 - 将其转换为 SSH。 Go to Settings –> Remotes and check if it is like ssh://git@github.com/GIT_ACCOUNT_NAME/GIT_REPO_NAME.git转到设置 –> 远程并检查它是否像ssh://git@github.com/GIT_ACCOUNT_NAME/GIT_REPO_NAME.git

  4. Check Sourcetree –> Preferences –> Accounts that you are using OAuth authorisation and SSH protocol.检查Sourcetree –> Preferences –> Accounts您正在使用 OAuth 授权和 SSH 协议。

  5. In Sourcetree –> Preferences –> Git switch to system git .Sourcetree –> Preferences –> Git切换到系统 git

  6. Good luck!祝你好运!

Convert the repo to SSH the issue might be that it would have been set to将 repo 转换为 SSH 问题可能是它会被设置为

样本图像

就我而言,我必须允许 SourcetreeForWindows 在我的组织 i GitHub 中进行第三方访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM