Improve platform support of help text by breaking git init into two commands
Problem to solve
The command line instructions for pushing an existing repo do not work by default on the latest LTS of Ubuntu. Currently the instructions are:
cd existing_folder
git init --initial-branch=main
git remote add origin git@gitlab.com:path/to/project.git
git add .
git commit -m "Initial commit"
git push -u origin main
As of 2021-12-14 the latest version of git available for ubuntu without needing to mess with package repositories is git version 2.25.1 which does not yet support the --initial-branch option.
> git init --initial-branch=main
error: unknown option `initial-branch=main'
Ubuntu is a common linux distribution picked up by novices aspiring to become professionals in software and supporting them in that pursuit seems like a good thing.
This is pretty much a non-obnoxious version of #337936 (closed) and I'm hoping the proposed solution may be more workable.
Proposal
Break the git init --initial-branch=main out into two commands until the versions of git supporting --initial-branch are more widely distributed.
cd existing_folder
git init
git checkout -b main
git remote add origin git@gitlab.com:path/to/project.git
git add .
git commit -m "Initial commit"
git push -u origin main
This appears to accomplish the same goal (It doesn't look like there is a vestigial master branch) while also having broader support across platforms.
Intended users
The git novice that is likely to lean heavily on the provided help text while they are learning.