Create a Repository
Before You Start
- Ensure you have Git version 2.28 or later. Check your version with:
git --version
- Set your local default Git branch to
main
by running:git config --global init.defaultBranch main
Create the Repository on GitHub
- Create a GitHub account if you haven't already.
- Click the "+" button on GitHub to create a new repository.
- Name it "git-test," check "Add a README file," and click "Create repository."
Clone the Repository to Your Local Machine
- Click the green "Code" button on your GitHub repository.
- Select the SSH option, copy the displayed URL.
- Open your terminal and create a directory named "repos" in your home folder:
mkdir ~/repos
- Move into the new directory:
cd ~/repos
- Clone the repository using the copied URL:
git clone git@github.com:USER-NAME/REPOSITORY-NAME.git
- Verify the connection:
cd git_test
andgit remote -v
You've successfully connected your GitHub repository to your local machine. The remote connection is named "origin," a default convention.