【问题标题】:Error when initializing the local directory as a Git repository [duplicate]将本地目录初始化为 Git 存储库时出错 [重复]
【发布时间】:2021-02-22 15:59:26
【问题描述】:

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

在第 4 步之前一切正常。然后我收到此错误:

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

我在这里做错了什么?

【问题讨论】:

标签: git github


【解决方案1】:

你可以这样做:

# 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

【讨论】:

    猜你喜欢
    • 2016-04-12
    • 1970-01-01
    • 2014-03-25
    • 2016-03-11
    • 1970-01-01
    • 2022-10-18
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    相关资源
    最近更新 更多