在gitlab

问题描述 投票:0回答:1

I在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
我的项目仍然是空的,我无法添加或推动任何东西。为什么?

Edit:如果我导航到项目并做

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
    
git gitlab commit
1个回答
2
投票
LLE的错误将错误一个人击倒。

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

是Windows中不存在的 *nix命令。一种选项是使用Git Bash而不是CMD,它提供了可执行文件。另外,您可以使用其他方法在Windows

中创建一个空文件。
C:\Users\me\myproject>touch README.md 'touch' is not recognized as an internal or external command, operable program or batch file.

这些两个命令没有失败,他们什么也没做,因为没有创建
touch

文件。创建它后,您可以重复这两个命令,它们应该成功。


repo-session
强制的
得分:0.00%(已完成检查:0.00%)
在您的alx-Zero_day repo中创建一个名为0x03-GIT的新目录。
确保您在目录中包含一个不是空的readme.md:

在您的存储库Alx-Zero_day的根部 并在目录中0x03-Git 重要的部分:确保您的提交并将代码推向GitHub-否则检查员将始终失败。 rrepo:
GITHUB存储库:alx-Zero_day

	

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.