'git init -b<分支名称>'终端中的命令抛出“未知开关"错误 [英] 'git init -b <branch name>' command in terminal is throwing an 'unknown switch' error

查看:665
本文介绍了'git init -b<分支名称>'终端中的命令抛出“未知开关"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用命令行将现有项目添加到GitHub.我在终端的相关工作目录中,并尝试使用 git init -b main 命令.

I am trying to add an existing project to GitHub using the command line. I am in the relevant working directory in the terminal and am trying to use the git init -b main command.

最初,我收到与xcode相关的错误:

Initially, I was getting an error relating to xcode:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

我尝试了 xcode-select --install ,但是更新服务器上没有该软件,因此我从

I tried xcode-select --install but the software was unavailable from the update server, so I downloaded 'Command Line Tools for Xcode 12' from https://developer.apple.com/download/more/.

现在输入 git init -b main 时,我得到以下信息:

Now on entering git init -b main I am getting the following:

error: unknown switch `b'
usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]

--template <template-directory>
                      directory from which templates will be used
--bare                create a bare repository
--shared[=<permissions>]
                      specify that the git repository is to be shared amongst several users
-q, --quiet           be quiet
--separate-git-dir <gitdir>
                      separate git dir from working tree

我正在运行git版本:2.24.3(Apple Git-128)

I am running git version: 2.24.3 (Apple Git-128)

任何帮助,不胜感激!

推荐答案

<代码> git 2.24 没有选项 -b /-initial-branch .它已添加到 git 2.28 中.您需要升级才能使用该选项.

git 2.24 doesn't have option -b/--initial-branch. It was added in git 2.28. You need to upgrade to use the option.

或者,如@matt所说,创建一个仓库,然后重命名分支:

Or, as @matt said, create a repo and then rename the branch:

git init repo
cd repo
git branch -m master slave

这篇关于'git init -b&lt;分支名称&gt;'终端中的命令抛出“未知开关"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆