Working with GitHub
Working with GitHub

Introduction
GitHub is the most popular Git hosting service with over 100 million developers. It provides collaboration features beyond basic Git.
Creating a GitHub Account
1. Go to github.com 2. Click "Sign up" 3. Follow the verification process 4. Choose your plan (free is sufficient for most features)
Creating a Repository on GitHub
Via Web Interface
1. Click the "+" icon in the top right 2. Select "New repository" 3. Enter repository name 4. Choose public or private 5. Optionally add README, .gitignore, or license 6. Click "Create repository"
Via Command Line
# Create local repository
mkdir my-project
cd my-project
git init
git add .
git commit -m "Initial commit"Create remote repository using GitHub CLI
gh repo create my-project --public --source=. --clone=false
Connecting Local Repository to GitHub
Method 1: HTTPS
git remote add origin https://github.com/username/repo.git
git push -u origin main
Method 2: GitHub CLI
gh repo create my-project --public
This creates and links in one step.
GitHub Key Features
Issues
Track bugs, features, and tasks:
## Issue TitleDescription
Describe the problem...Steps to Reproduce
1. Go to...
2. Click on...
3. See errorExpected Behavior
What should happen...Actual Behavior
What actually happens...
Pull Requests
Propose changes to a repository:
1. Fork the repository 2. Create a branch 3. Make changes 4. Open a Pull Request 5. Discuss and review 6. Merge
GitHub Actions
Automate workflows:
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: npm test
GitHub Pages
Host static websites directly from your repository.
Forking and Contributing
Fork a Repository
Click "Fork" button on any GitHub repository.
Clone Your Fork
git clone https://github.com/your-username/repository.git
Add Upstream
git remote add upstream https://github.com/original-owner/repository.git
Keep Fork Updated
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
Create Pull Request
1. Push your changes to your fork 2. Navigate to original repository 3. Click "New Pull Request" 4. Select your branch 5. Add description 6. Submit
GitHub CLI
Installation
# macOS
brew install ghUbuntu
sudo apt install ghWindows
winget install GitHub.cli
Authentication
gh auth login
Useful Commands
# List repositories
gh repo listCreate repository
gh repo create my-repoClone repository
gh repo clone owner/repoCreate issue
gh issue create --title "Bug" --body "Description"Create pull request
gh pr create --title "Feature" --body "Description"View PR status
gh pr status
GitHub Desktop
For a GUI experience:
1. Download from desktop.github.com 2. Sign in to your account 3. Clone or create repositories 4. Make commits and push with visual interface
Best Practices
Commit Messages
- Use imperative mood: "Add feature" not "Added feature"
- First line under 50 characters
- Detailed description after blank line
Pull Request Etiquette
- Keep PRs small and focused
- Include description of changes
- Reference related issues
- Respond to review comments
README Best Practices
# Project NameBrief description.
Installation
bash
npm install
Usage
bash
npm start
Contributing
Explain how others can contribute.
License
MIT
Summary
GitHub extends Git with powerful collaboration features:
- Remote repository hosting
- Issues for tracking
- Pull Requests for contributions
- GitHub Actions for automation
- GitHub Pages for hosting
Next Lesson
Learn about SSH keys for secure authentication with GitHub.
Quiz - Quiz - Working with GitHub
1. What is a Pull Request?
2. What is forking in GitHub?
3. What GitHub feature automates workflows?
4. What is the GitHub CLI command to create a repository?
5. How do you keep a fork synchronized with the original repository?