在 GitLab 中创建 README.md

Creating a README.md in GitLab

我在 GitLab(在浏览器中)中创建了一个新的空白项目。我选中了“使用自述文件初始化存储库”框。但是当打开它时,它说:“这个项目的存储库是空的。”我假设我仍然需要初始化一个 README.md 文件以便主分支存在?所以在我尝试的命令行中(我正在使用 windows 10):

git clone https://gitlab.com/url/myproject.git
cd myproject
git switch -c main
touch README.md
git add README.md
git commit -m "add README"

但是它说:

C:\Users\me>git clone https://gitlab.com/ur/myproject.git
fatal: destination path 'myproject' already exists and is not an empty directory.

C:\Users\me>cd myproject

C:\Users\me\myproject>git switch -c main
fatal: A branch named 'main' already exists.

C:\Users\me\myproject>touch README.md
'touch' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\me\myproject>git add README.md

C:\Users\me\myproject>git commit -m "add README"

On branch main
Your branch is based on 'origin/main', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

nothing to commit, working tree clean

我的项目还是空的,我不能添加或推送任何东西。为什么?

编辑:如果我导航到项目并执行 dir,我得到(我只删除了卷序列号):

C:\Users\me\myproject>dir
 Volume in drive C has no label.
 Volume Serial Number is ...

 Directory of C:\Users\me\myproject

13.12.2021  09:29    <DIR>          .
13.12.2021  09:29    <DIR>          ..
13.12.2021  09:29                 0 README.md
               1 File(s)              0 bytes
               2 Dir(s)  112.515.997.696 bytes free

让我们一一分解错误。

C:\Users\me>git clone https://gitlab.com/ur/myproject.git
fatal: destination path 'myproject' already exists and is not an empty directory.

myproject 文件夹已经存在 - 很可能您已经克隆了该项目,因此无需在此执行更多操作。

C:\Users\me\myproject>git switch -c main
fatal: A branch named 'main' already exists.

您无法创建 main 分支,因为它已经存在 - 再次声明,这里无事可做。

C:\Users\me\myproject>touch README.md
'touch' is not recognized as an internal or external command,
operable program or batch file.

touch 是 Windows 中不存在的 *nix 命令。一种选择是使用 Git Bash 而不是 CMD,它提供 touch 可执行文件。或者,您可以使用 another method to create an empty file in Windows.

C:\Users\me\myproject>git add README.md

C:\Users\me\myproject>git commit -m "add README"

On branch main
Your branch is based on 'origin/main', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

nothing to commit, working tree clean

这两个命令并没有失败,它们只是什么也没做,因为 README.md 文件没有创建。创建后,您可以重复这两个命令,它们应该会成功。

  1. Repo-session 强制的 分数:0.00%(检查完成:0.00%) 在您的 alx-zero_day 存储库中创建一个名为 0x03-git 的新目录。

确保在您的目录中包含一个非空 README.md:

在您存储库的根目录下 alx-zero_day AND 在目录 0x03-git 重要的部分:确保您提交并将代码推送到 Github - 否则检查器将始终失败。

回购:

GitHub 存储库:alx-zero_day