Ubuntu 18.04 (Bionic) ships git 2.17.1 — before `git switch` and `git restore` (added in 2.23) and before `init.defaultBranch` (added in 2.28). Scripts or tutorials using these commands will fail. Ubuntu 18.04 is also EOL (April 2023). Install a newer git via the git-core PPA or upgrade the OS.
Workarounds & Fixes
Use `git checkout` instead of `git switch` or `git restore`