Before starting, do two things to ensure things run smoothly:
- make sure you’re running version 2.28 or later of git. You can check your version with
git --version. - Set your local default git branch to
main. You can do so by running:git config --global init.defaultBranch main
Create your new repo in three steps:
- Log in to GitHub and click the + dropdown and click Create Repository.
- Type your repo name and check the box to add a README.txt file.
- Finally, click the green Create Repository button.
Clone the repo to your local computer:
- Open the repository you want to clone to your local machine.
- Click the green Code dropdown button.
- Choose SSH and click the copy button.
- Open Terminal (Mac OS) on your computer and cd into the folder you want to copy the repo into.
- Type git clone and paste the SSH text you’ve copied, which will look something like this
git clone git@github.com:username/reponame.git - That’s it; once it’s downloaded, you’ll see all the files in your local machine’s folder.
Optionally, if you don’t want to start off with GitHub, you can do this locally with git.
- Open Terminal and navigate to where you want to create this repository.
- Type
mkdir nameofyourrepocreatethencd nameofyourrepocreate - Once in the directory, type
git-init - Now you can create a file and use
git addandgit committo save those changes in the local repository history.
Extra reading:
- https://docs.github.com/en/get-started/quickstart/create-a-repo
- https://git-scm.com/docs/git-init

Leave a Reply