How to Get Started with GitHub

Episode 2 - Setting Up a GitHub Account

Table of contents

  1. Recap of Episode 1: Mastering Git and GitHub Basics

  2. Step-by-step guide to installing and configuring git

  3. Installing GitHub on your Desktop

  4. Creating Your First Repository: A Beginner's Guide

  5. Conclusion

Recap of Episode 1: Mastering Git and GitHub Basics

In Episode 1 of "How to Get Started with GitHub," we introduced the basics of Git and GitHub, providing a comprehensive guide for both beginners and experienced developers. The episode covered essential concepts such as VCS, types of VCS, the difference between Git and GitHub, and repositories. We walked through the steps to install and configure Git, create a repository, and connect a local repository to a remote one on GitHub. Additionally, we explained how to set up a GitHub account. By the end of the episode, readers gained a solid foundation in using Git and GitHub to streamline their coding workflow and collaborate effectively on projects.

Check out the link for Episode 1 of this series: https://itsmedeepika.hashnode.dev/github-basics-key-information-for-new-users

Step-by-step guide to installing and configuring git

  1. Download Git: Visit the official Git website at git-scm.com and download the appropriate version for your operating system (Windows, macOS, or Linux).

  2. Install Git:

    • Windows: Run the downloaded .exe file and follow the installation prompts. You can use the default settings unless you have specific preferences.

    • macOS: You can install Git using Homebrew. Open Terminal and run brew install git. Alternatively, you can download the installer from the Git website and follow the prompts.

    • Linux: Use the package manager for your distribution. For example, on Ubuntu, run sudo apt-get install git.

  3. Verify Installation: Open your terminal or command prompt and type git --version. You should see the installed version of Git, confirming the installation was successful.

  4. Configure Git:

  5. Check Configuration: To verify your configuration settings, run git config --list. This command will display all the Git configuration settings, including your username and email.

  6. Set Up a Text Editor: Git uses a text editor for commit messages. You can set your preferred editor with the following command:

    • For Nano: git config --global core.editor nano

    • For Vim: git config --global core.editor vim

    • For VS Code: git config --global core.editor "code --wait"

  7. Generate SSH Key (Optional but Recommended):

    • Run ssh-keygen -t rsa -b 4096 -C "your.email@example.com". Follow the prompts to save the key.

    • Add the SSH key to your SSH agent by running eval "$(ssh-agent -s)" followed by ssh-add ~/.ssh/id_rsa.

    • Copy the SSH key to your clipboard with cat ~/.ssh/id_rsa.pub and add it to your GitHub account under Settings > SSH and GPG keys.

    • Generating an SSH key in Git is important for several reasons:

      1. Secure Authentication: SSH keys provide a safe way to authenticate with Git repositories, reducing the risk of unauthorized access compared to using passwords.

      2. Passwordless Access: Once set up, SSH keys let you access your Git repositories without needing to enter your username and password each time, making your workflow smoother.

      3. Encryption: SSH keys ensure that the data transmitted between your local machine and the Git server is encrypted, protecting it from eavesdropping and tampering.

      4. Automation: SSH keys are essential for automating tasks such as continuous integration and deployment, where scripts need to interact with Git repositories without manual intervention.

      5. Access Control: SSH keys make it easy to manage access to your repositories. You can add or remove public keys to grant or revoke access without changing passwords.

Overall, using SSH keys with Git enhances security, convenience, and efficiency in managing and accessing your repositories.

  1. Clone a Repository (Optional): To test your setup, you can clone a repository. Run git clone https://github.com/username/repository.git, replacing "username" and "repository" with the appropriate values.

By following these steps, you will have Git installed and configured on your system, ready for collaboration.

Installing GitHub on your Desktop:

  1. Download GitHub Desktop: Visit the official GitHub Desktop website at desktop.github.com and download the appropriate version for your operating system (Windows or macOS).

  2. Install GitHub Desktop:

    • Windows: Run the downloaded .exe file and follow the installation prompts.

    • macOS: Open the downloaded .dmg file and drag the GitHub Desktop icon to your Applications folder.

  3. Launch GitHub Desktop: Open the GitHub Desktop application from your Start menu (Windows) or Applications folder (macOS).

  4. Sign In to GitHub: When you first open GitHub Desktop, you will be prompted to sign in to your GitHub account. Enter your GitHub username and password, or use the browser to authenticate.

  5. Configure Git: If you haven't already configured Git, GitHub Desktop will prompt you to set your name and email address. This information will be used for your commits.

  6. Clone a Repository:

    • Click on "File" in the menu bar and select "Clone Repository."

    • You can choose to clone a repository from GitHub.com, GitHub Enterprise, or by providing a URL.

    • Select the repository you want to clone and choose a local path where you want to save it.

  7. Create a New Repository:

    • Click on "File" in the menu bar and select "New Repository."

    • Fill in the repository name, description, and local path where you want to create it.

    • Optionally, you can initialize the repository with a README, ..gitignore, or license.

  8. Manage Your Repositories: Use GitHub Desktop to manage your repositories. You can commit changes, create branches, merge branches, and push your changes to GitHub.

  9. Sync Changes: GitHub Desktop makes it easy to sync changes between your local repositories and GitHub. Use the "Fetch origin" button to pull changes from GitHub and the "Push origin" button to push your local changes to GitHub.

By following these steps, you will have GitHub Desktop installed and configured, allowing you to manage your repositories with a user-friendly interface.

Creating Your First Repository: A Beginner's Guide

Creating your first repository on GitHub is a straightforward process. Follow these steps to get started:

  1. Sign In to GitHub: Go to GitHub.com and sign in with your GitHub account. If you don't have an account, you'll need to create one.

  2. Create a New Repository:

    • Click on the "+" icon in the upper-right corner of the GitHub page and select "New repository."

    • Alternatively, you can go directly to https://github.com/new.

  3. Repository Details:

    • Repository Name: Enter a name for your repository. This name should be unique within your GitHub account.

    • Description: (Optional) Provide a short description of your repository.

    • Public or Private: Choose whether your repository will be public (visible to everyone) or private (only you and people you explicitly share it with can see it).

  4. Initialize the Repository:

    • Initialize with a README: Check this box to add a README file. A README file is a great place to describe your project.

    • .gitignore: (Optional) Select a .gitignore template if you want to exclude certain files from being tracked by Git.

    • License: (Optional) Choose a license for your repository. This is important if you want to specify how others can use your code.

  5. Create Repository: Click the "Create repository" button to create your new repository.

  6. Clone the Repository Locally:

    • Once the repository is created, you will be taken to the repository's main page.

    • Click the "Code" button and copy the URL of the repository.

    • Open your terminal or Git Bash and navigate to the directory where you want to clone the repository.

    • Run the command git clone <repository-url>, replacing <repository-url> with the URL you copied.

  7. Add Files and Make Your First Commit:

    • Navigate to the cloned repository directory on your local machine.

    • Add files to your repository. You can create new files or copy existing files into this directory.

    • Use the following commands to stage, commit, and push your changes:

        git add .
        git commit -m "Initial commit"
        git push origin main
      
  8. Verify on GitHub: Go back to your repository on GitHub and refresh the page. You should see the files you added and your initial commit message.

By following these steps, you will have successfully created your first repository on GitHub and made your initial commit. This is the foundation for managing your projects and collaborating with others using GitHub.

Conclusion

By following the steps in this guide, you will have successfully set up a GitHub account, installed and configured Git, and created your first repository. These foundational skills are essential for managing your projects and collaborating with others using GitHub. In this episode, we covered some basic commands. Don't worry if you don't understand why we use these commands; in the next episode, we will go into detail about Git commands. Whether you're a beginner or looking to improve your workflow, mastering these basics will greatly enhance your development experience. Stay tuned for more episodes in this series to further expand your GitHub knowledge and skills.