Git: 'switch' is not a git command. See 'git --help'

Hello World!

I’m using GitLab 14.1.1 (community edition), while creating new projects I didn’t specify to add README.md and now trying to follow Create a new repository step, yet running into an issue:

    # git clone ssh://git@X.X.X:X/X/X.git
    Cloning into 'X'...
    warning: You appear to have cloned an empty repository.
    # cd X/
    # git switch -c main
    git: 'switch' is not a git command. See 'git --help'.
    # touch README.md
    # git add README.md
    # git commit -m "add README"
    [master (root-commit) ef96bce] add README
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 README.md
    # git push -u origin main
    error: src refspec main does not match any.
    error: failed to push some refs to 'ssh://git@X.X.X:X/X/X.git'
    #

# git --version
git version 2.11.0
#

Please advise.

instead of using

# git switch -c main

I use following instead:

# git checkout -b main
Switched to a new branch 'main'
# 
1 Like