A quick access to Git commands to setup a new repo on a Git Hosting Service.
There are several Git Hosting Services such as GitHub, GitLab, Bitbucket, Azure DevOps Repos and more.
Create a new repository on the command line
echo "# <Your Project Name>" >> README.md
git init
git add README.md
git commit -m "First commit"
git branch -M main
git remote add origin https://<your-git-hosting-service>/<your-repo-name>.git
git push -u origin main
…or push an existing repository from the command line
git remote add origin https://<your-git-hosting-service>/<your-repo-name>.git
git branch -M main
git push -u origin main
Checkout your Git Repo where you need it
git clone https://<your-git-hosting-service>/<your-repo-name>.git
git checkout <branch-name>