Git GitHub Operations
GitHub is the world's largest code hosting platform. This chapter details how to interact with GitHub using Git, including repository management, collaborative development, Pull Requests, and more.
GitHub Basic Concepts
What is GitHub?
GitHub is a Git-based code hosting platform that provides:
- 🏠 Code Hosting: Remote repository storage
- 👥 Collaborative Development: Team collaboration tools
- 🔍 Code Review: Pull Request mechanism
- 🚀 CI/CD: GitHub Actions automation
- 📊 Project Management: Issues, Projects, Wiki
GitHub vs Git
Creating and Configuring GitHub Repositories
Creating a Repository on GitHub
- Log in to GitHub
- Click the "+" button in the top right corner
- Select "New repository"
- Fill in repository information:
- Repository name
- Description
- Public/Private
- Initialize with README
- Add .gitignore
- Choose a license
Connecting Local Repository to GitHub
Method 1: Clone an Existing Repository
Method 2: Push an Existing Local Repository
SSH Key Configuration
Generating SSH Keys
Adding SSH Key to GitHub
Then on GitHub:
- Go to Settings → SSH and GPG keys
- Click "New SSH key"
- Paste the public key content
- Add a descriptive title
- Click "Add SSH key"
Testing SSH Connection
Basic GitHub Operations
Pushing Code to GitHub
Pulling Updates from GitHub
Viewing Remote Repository Information
Fork and Pull Request Workflow
Forking a Repository
- Find the project you want to contribute to on GitHub
- Click the "Fork" button in the top right corner
- Choose to Fork to your account
Cloning a Forked Repository
Keeping Fork Synced
Creating Feature Branches
Creating a Pull Request
- Visit your Fork on GitHub
- Click the "Compare & pull request" button
- Fill in PR information:
- Title: Concisely describe the changes
- Description: Explain changes in detail
- Select the correct base branch and compare branch
- Click "Create pull request"
Pull Request Template
GitHub Issues Management
Creating an Issue
Issue Template
Linking Issues in Commits
GitHub Actions Basics
Creating a Simple CI Workflow
Auto-Deployment Workflow
GitHub Advanced Features
GitHub Pages
GitHub Releases
GitHub Discussions
Team Collaboration Best Practices
Branch Protection Rules
Configure branch protection in GitHub repository settings:
Code Review Workflow
Project Management
GitHub CLI Usage
Installing GitHub CLI
Common GitHub CLI Commands
Troubleshooting
Common GitHub Issues
GitHub API Limits
Security Best Practices
Protecting Sensitive Information
Access Control
Summary
Key points of GitHub operations:
Basic Operations
Collaboration Workflow
- 🍴 Fork Workflow: Suitable for open source contributions
- 🌿 Branch Workflow: Suitable for team collaboration
- 📋 Issue Tracking: Manage tasks and Bugs
- 🔍 Code Review: Ensure code quality
Automation Tools
- ⚡ GitHub Actions: CI/CD automation
- 🚀 GitHub Pages: Static website hosting
- 📦 GitHub Releases: Version release management
- 💬 GitHub Discussions: Community discussions
Best Practices
- ✅ Configure SSH key authentication
- ✅ Use branch protection rules
- ✅ Write clear PR descriptions
- ✅ Sync Fork timely
- ✅ Protect sensitive information
After mastering GitHub operations, you will be able to:
- 🤝 Collaborate efficiently with teams
- 🔄 Contribute to open source projects
- 🚀 Automate development and deployment processes
- 📊 Effectively manage project progress
In the next chapter, we will learn the Git glossary.