Published on

A Step-by-Step Guide to Creating a Repository on GitHub

Authors

Introduction

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.

This tutorial will help you to create a repository on GitHub.

Prerequisites

  • GitHub account
  • Git installed on your local machine

Steps to Create a Repository on GitHub

  1. Login to your GitHub account.
  2. Click on the + icon on the top right corner of the page.
  1. Click on New repository.
  1. Enter the repository name and description.
  1. Select the repository type (Public or Private) and click on the Initialize this repository with a README option.
  1. Click on the Create repository button.
  1. Copy the repository URL by clicking on the Code button and selecting the HTTPS option.

Step 7 image

  1. Open the terminal on your local machine.

  2. Navigate to the directory where you want to create the repository.

  3. Run the following command to create a new repository:

git init
  1. Run the following command to add the files to the staging area:
git add .
  1. Run the following command to commit the changes:
git commit -m "Initial commit"
  1. Run the command to change the default branch name from master to main.
git branch -M main
  1. Run the following command to add the remote repository URL you copied in step 7:
git remote add origin `<repository-url>`
  1. Run the following command to push the changes to the remote repository:
git push -u origin main

Conclusion

Congratulations! You have successfully created a repository on GitHub and pushed the changes to the remote repository using Git commands on your local machine 🎉

The End! 🎉

Thank you for reading! Happy Coding! 😊 Hope you follow me on GitHub and Twitter. See you in the next blog. Take care!👋