将本地目录初始化为Git存储库时出错

将本地目录初始化为Git存储库时出错,git,github,Git,Github,我在GitHub上有一个现有的存储库。它是私有的,所以很抱歉我不能提供URL作为这个问题的一部分。我在文件夹里有一些代码。此文件夹没有.git文件夹。我想将此文件夹与远程存储库“连接”或“链接”。我正在使用 到第4步,一切都很顺利。然后我得到这个错误: % git init -b main error: unknown switch `b' 我做错了什么?你可以这样说: # Initialize a git repo on current folder git init . # Stage

我在GitHub上有一个现有的存储库。它是私有的,所以很抱歉我不能提供URL作为这个问题的一部分。我在文件夹里有一些代码。此文件夹没有.git文件夹。我想将此文件夹与远程存储库“连接”或“链接”。我正在使用

到第4步,一切都很顺利。然后我得到这个错误:

% git init -b main
error: unknown switch `b'

我做错了什么?

你可以这样说:

# Initialize a git repo on current folder
git init .

# Stage all objects in current folder (including subfolders)
git add .

# Commit git changes
git commit -m "First Commit"

# Add a Remote Git Repo
git remote add origin https://github.com/xxxx

# Finally push changes from local repo to remote repo
git push origin main

结果是什么:Git--version?我这么问是因为-b是从Git版本2.28添加的。。。。