【问题标题】:Creating a git repo for an existing R project - "fatal: Couldn't find remote ref master" error为现有 R 项目创建 git 存储库 - “致命:找不到远程参考主控”错误
【发布时间】:2021-07-16 20:11:28
【问题描述】:

我想最终开始为我的 R 项目使用版本控制。我开始关注this guide,创建了一个空仓库,但是当我进入命令行部分时问题就开始了。

首先我做到了:

git remote add origin https://github.com/username/repo_name.git

但是在我输入之后:

git pull origin master

我收到此错误:

fatal: Couldn't find remote ref master

现在,如果我尝试以下操作:

git remote -v

我明白了:

origin  https://github.com/username/repo_name.git (fetch)
origin  https://github.com/username/repo_name.git (push)

所以有些东西在起作用。我是git 的新手,不确定问题出在哪里。

为了解决这个问题,我为存储库添加了一个文件 (file.R),但除此之外,存储库是空的。我得到了和以前一样的错误。

如果我在终端上尝试git branch -r,我不会得到任何回报。

【问题讨论】:

  • 你试过git branch -r来检查你的本地仓库知道哪些远程分支?
  • 我得到repo (即存储库名称)
  • 你应该得到一个以origin/为前缀的分支列表,origin/master就是其中之一。
  • 你是如何克隆它的? (如果您不确定,该命令应该在您的history 中)
  • 我做了git remote add origin https://github.com/username/repo_name.git,我已经编辑了问题以包含它。

标签: r git rstudio


【解决方案1】:

如果您从在 GitHub 中创建一个空的 repo 开始,那么 the default branch is no longer master。默认分支现在是main

如果您首先使用git init 在本地创建新的存储库,那么请检查您的默认分支使用git branch。这应该会显示mainmaster 分支。

使用简单的README.md.gitignore 在 GitHub 中创建存储库可能更容易,然后将该存储库克隆到另一个文件夹。将您的代码移动到该存储库中,添加并提交所有内容,然后将您的代码推送到 GitHub。

【讨论】:

    猜你喜欢
    • 2014-08-18
    • 2014-03-01
    • 2022-10-23
    • 1970-01-01
    • 2015-03-07
    • 2019-10-24
    • 2012-04-15
    • 2012-10-08
    • 2012-12-12
    相关资源
    最近更新 更多