为现有 R 项目创建 git 存储库 - "fatal: Couldn't find remote ref master" 错误

Creating a git repo for an existing R project - "fatal: Couldn't find remote ref master" error

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

我首先做了:

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,我在 return 中什么也得不到。

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

如果您首先使用 git init 在本地创建一个新的存储库,然后检查您的默认分支正在使用什么 git branch。这应该向您显示 mainmaster 分支。

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