Getting Started with GitHub

A Step-by-Step Guide : Github

Table of contents

No heading

No headings in the article.

Are you new to GitHub and curious about how to create a repository, make changes, and push them back to the remote repository? Look no further! In this blog, we'll walk you through the simple process of setting up your first repository on GitHub, making changes, and pushing them back to the remote repository.

Step 1: Create a New Repository on GitHub

  1. Go to https://github.com and log in to your GitHub account. If you don't have an account, sign up for free.

  2. Once logged in, click on the "+" button on the top right corner of the GitHub dashboard and select "New repository."

  3. Give your repository a meaningful name, a brief description, and choose whether it should be public or private.

  4. Click on the "Create repository" button to create your new repository.

Step 2: Clone the Repository to Your Local Machine

  1. Open your preferred terminal or command prompt on your local machine.

  2. Navigate to the directory where you want to clone the repository. You can use the cd command to change directories.

  3. On the GitHub repository page, click on the green "Code" button and copy the repository's URL.

  4. In your terminal, type the following command and replace <repository-url> with the URL you copied:

     git clone <repository-url>
    
  5. Press Enter to clone the repository to your local machine.

Step 3: Make Changes to a File in the Repository and Commit

  1. Open the cloned repository on your local machine using your favorite code editor.

  2. Make the desired changes to the file(s) in the repository.

  3. Save the changes you made in the file(s).

  4. Now, let's commit the changes locally using Git:

    • Open your terminal or command prompt.

    • Navigate to the root folder of your cloned repository using the cd command.

    • Use the following commands to commit the changes:

        git add .    # This stages all the changes you made.
        git commit -m "Your commit message here"    # Replace the message with a brief description of your changes.
      

Step 4: Push the Changes Back to GitHub

  1. After committing your changes, it's time to push them back to the remote repository on GitHub:

     git push origin main    # If you're using the main branch. If your default branch is named differently, use that name instead of 'main'.
    
  2. Enter your GitHub username and password (or, if you've set up SSH keys, you won't need to enter your credentials).

  3. Press Enter, and Git will push your changes to the remote repository.

Congratulations! You've successfully created a new repository on GitHub, cloned it to your local machine, made changes to a file, and pushed those changes back to the remote repository.

With this basic understanding, you can now collaborate with others on projects, explore version control, and contribute to the world of open-source software. Happy coding!