Table of contents
Brief Overview
On Day 7, we will cover:
What GitHub Is: An introduction to GitHub and its purpose.
Setting Up a GitHub Account: How to create a GitHub account.
SSH Key Authentication: Setting up SSH keys for secure authentication with GitHub.
Detailed Explanation
1. What GitHub Is
GitHub is a cloud-based platform that provides version control and collaboration features for software development. It is built around Git, a distributed version control system created by Linus Torvalds.
Primary Purpose:
Code Hosting: GitHub hosts Git repositories online, making code accessible from anywhere and enabling collaboration.
Collaboration: GitHub allows multiple developers to work on the same project, track changes, and manage code effectively.
Project Management: GitHub offers tools for tracking issues, managing projects, and reviewing code changes.
Key Features:
Repositories: Centralized storage for project files and history.
Issues: Track tasks, bugs, and feature requests.
Pull Requests: Propose, review, and merge changes to the codebase.
Branches: Work on features or fixes independently.
Forks: Create personal copies of repositories for experimentation.
GitHub Actions: Automate workflows like continuous integration and deployment.
2. Setting Up a GitHub Account
To use GitHub, you need to create a GitHub account. Follow these steps to set up your account:
Visit the GitHub Website: Go to Github Website.
Sign Up for an Account:
Click on the "Sign up" button.
Enter your email address, create a password, and choose a username.
Follow the prompts to complete the sign-up process, including verifying your email address.
Set Up Your Profile:
After signing up, log in to your GitHub account.
Click on your profile icon in the top right corner and select "Your profile."
Click "Edit profile" to add details such as your name, bio, and profile picture.
Create a New Repository:
Click on the "+" icon in the top right corner and select "New repository."
Fill in the repository name, description, and other settings.
Click "Create repository" to set up your first project.
3. SSH Key Authentication
SSH (Secure Shell) keys are a way to authenticate with GitHub securely. Setting up SSH keys allows you to connect to GitHub without needing to enter your username and password every time.
Steps to Set Up SSH Key Authentication:
Generate an SSH Key: If you don’t already have an SSH key, you’ll need to generate one.
For Windows: Open Git Bash and run the following command:
ssh-keygen -t ed25519 -C "your_email@example.com"
Follow the prompts to save the key to the default location (e.g.,
~/.ssh/id_ed25519
).For macOS/Linux: Open Terminal and run:
ssh-keygen -t ed25519 -C "your_email@example.com"
Follow the prompts to save the key.
Add the SSH Key to the SSH Agent: Ensure the SSH agent is running and add your SSH private key.
# Start the SSH agent eval "$(ssh-agent -s)" # Add your SSH key to the agent ssh-add ~/.ssh/id_ed25519
Copy the SSH Key: Copy the contents of your SSH public key to your clipboard.
# For macOS pbcopy < ~/.ssh/id_ed25519.pub # For Linux cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard # For Windows cat ~/.ssh/id_ed25519.pub | clip
Add the SSH Key to Your GitHub Account:
Click "New SSH key."
Paste your SSH key into the "Key" field and give it a descriptive title.
Click "Add SSH key."
Test Your SSH Connection: Verify that your SSH key is correctly configured.
ssh -T git@github.com
If everything is set up correctly, you should see a message like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Example Workflow with SSH Authentication:
Clone a Repository Using SSH:
git clone git@github.com:username/repository-name.git
Push Changes Using SSH:
git push origin main
By the end of Day 7, we should have a clear understanding of what GitHub is, how to set up a GitHub account, and how to use SSH key authentication for secure and convenient access to your GitHub repositories.