Git & GitHub

GitHub Advanced Features

13 min Lesson 33 of 35

GitHub Advanced Features

In this lesson, we'll explore advanced GitHub features that go beyond basic Git functionality. These tools can enhance your documentation, collaboration, and overall project management on the platform.

GitHub Pages - Hosting Websites

GitHub Pages allows you to host static websites directly from your GitHub repository for free:

Types of GitHub Pages Sites: 1. User/Organization Site: - Repository: username.github.io - URL: https://username.github.io - Deploy from main branch 2. Project Site: - Any repository - URL: https://username.github.io/repo-name - Deploy from main, gh-pages branch, or /docs folder

Setting up GitHub Pages:

# Method 1: Deploy from main branch 1. Go to repository Settings 2. Navigate to Pages section 3. Select "Deploy from branch" 4. Choose "main" and "/ (root)" 5. Click Save # Method 2: Deploy from /docs folder 1. Create docs/ folder in your repository 2. Add your HTML files to docs/ 3. In Settings > Pages, select "main" and "/docs" 4. Your site will be available shortly # Method 3: Use GitHub Actions for build process name: Deploy to GitHub Pages on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build site run: npm run build - uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist
Use Cases: Portfolio websites, project documentation, blogs (with Jekyll), landing pages, and API documentation.

Custom domains for GitHub Pages:

# Add custom domain 1. Create CNAME file in repository root 2. Add your domain: www.yourdomain.com 3. In Settings > Pages, add custom domain 4. Configure DNS records with your domain provider: - Type: CNAME - Name: www - Value: username.github.io # Enable HTTPS (free with GitHub Pages) ✓ Automatically provided via Let's Encrypt ✓ Check "Enforce HTTPS" in settings

GitHub Gists - Code Snippets

Gists are simple way to share code snippets, notes, or small files:

Gist Features: ✓ Create public or secret gists ✓ Version control for each gist ✓ Embed gists in websites ✓ Fork and star gists ✓ Comment on gists ✓ Share with unique URL

Creating and using Gists:

# Create a Gist on GitHub.com 1. Go to gist.github.com 2. Add filename and code 3. Choose "Create public gist" or "Create secret gist" # Clone a Gist git clone https://gist.github.com/username/gist-id.git # Embed Gist in HTML <script src="https://gist.github.com/username/gist-id.js"></script> # Using GitHub CLI gh gist create myfile.js --public gh gist list gh gist view <gist-id> gh gist edit <gist-id>
Secret vs Private: Secret gists aren't searchable but can be accessed by anyone with the URL. They're not truly private but are hidden from search engines.

GitHub Discussions

GitHub Discussions provides a community forum within your repository:

Discussion Features: ✓ Community Q&A ✓ Announcements ✓ Ideas and feature requests ✓ Polls ✓ Categorized discussions ✓ Mark answers as correct ✓ Convert issues to discussions

Enabling and organizing Discussions:

# Enable Discussions 1. Go to repository Settings 2. Check "Discussions" under Features 3. Discussion tab appears in repository # Create Discussion Categories - Q&A: Community questions - Announcements: Project updates - Ideas: Feature suggestions - Show and tell: Community showcases - General: Everything else # Best practices ✓ Pin important discussions ✓ Set up discussion templates ✓ Use labels for organization ✓ Moderate discussions actively ✓ Link to discussions from README
When to use: Use Discussions for open-ended conversations. Use Issues for actionable bugs and tasks. Use PRs for code changes.

GitHub Wikis

Wikis provide comprehensive documentation space for your project:

# Enable Wiki 1. Go to Settings 2. Check "Wikis" under Features 3. Wiki tab appears # Wiki is actually a Git repository git clone https://github.com/username/repo.wiki.git # Edit locally, commit, and push # Wiki supports Markdown - Create pages with Markdown - Link between pages: [[Page Name]] - Add sidebar: _Sidebar.md - Add footer: _Footer.md - Add home page: Home.md

Organizing Wiki content:

Recommended Wiki Structure: Home.md # Wiki homepage Getting-Started.md # Installation and setup User-Guide.md # How to use the project API-Reference.md # API documentation Contributing.md # Contribution guidelines FAQ.md # Frequently asked questions Troubleshooting.md # Common problems and solutions _Sidebar.md # Navigation sidebar _Footer.md # Footer with links

Releases and Changelogs

Releases package your software with release notes and downloadable assets:

# Creating a Release 1. Go to Releases > Draft a new release 2. Choose or create a tag (e.g., v1.0.0) 3. Target: usually main branch 4. Write release notes 5. Upload binary files (optional) 6. Mark as pre-release if needed 7. Publish release # Semantic Versioning (SemVer) MAJOR.MINOR.PATCH - MAJOR: Breaking changes (2.0.0) - MINOR: New features, backwards compatible (1.3.0) - PATCH: Bug fixes (1.2.1) # Pre-release versions v1.0.0-alpha.1 v1.0.0-beta.2 v1.0.0-rc.1

Writing effective release notes:

# Release v2.1.0 - New Features and Bug Fixes ## What's New - Added dark mode support (#234) - Implemented user profile customization (#245) - New API endpoint for batch operations (#256) ## Bug Fixes - Fixed memory leak in data processing (#267) - Resolved authentication timeout issue (#271) - Corrected date formatting in exports (#278) ## Breaking Changes - Removed deprecated `oldFunction()` method - Changed API response format for /users endpoint ## Upgrade Instructions See [Migration Guide](link) for upgrade steps. ## Contributors Thanks to @user1, @user2, @user3 for contributions! **Full Changelog**: v2.0.0...v2.1.0
Important: Once a release is published, never modify the associated tag. Create a new release with a new version number instead.

GitHub CLI (gh command)

The GitHub CLI brings GitHub functionality to your terminal:

# Install GitHub CLI # macOS brew install gh # Windows winget install GitHub.cli # Linux sudo apt install gh # Authenticate gh auth login

Common gh commands:

# Repository operations gh repo create my-project --public gh repo clone username/repo gh repo view gh repo fork # Issue management gh issue list gh issue create --title "Bug report" --body "Description" gh issue view 123 gh issue close 123 # Pull request operations gh pr create --title "Feature" --body "Description" gh pr list gh pr checkout 456 gh pr review 456 --approve gh pr merge 456 --squash # Workflow operations gh workflow list gh workflow run ci.yml gh run list gh run view 789 # Gist operations gh gist create file.js gh gist list gh gist view <id> # Releases gh release create v1.0.0 --notes "Release notes" gh release list gh release download v1.0.0
Productivity Boost: Create aliases for common gh commands in your shell profile to save typing: alias gpr="gh pr create"

GitHub Mobile App

GitHub Mobile allows you to manage your projects on the go:

Mobile App Features: ✓ Review and merge pull requests ✓ Respond to issues and discussions ✓ Browse code with syntax highlighting ✓ Receive notifications ✓ Approve workflow runs ✓ Create and edit issues ✓ Comment on code and PRs ✓ Manage your profile Available on: - iOS (iPhone/iPad) - Android

Best practices for mobile workflow:

Good mobile tasks: ✓ Code review and comments ✓ Approving simple PRs ✓ Responding to issues ✓ Triaging notifications ✓ Quick documentation edits Better done on desktop: ✗ Complex code reviews ✗ Resolving merge conflicts ✗ Writing substantial code ✗ Extensive refactoring reviews

Organization Management

GitHub Organizations provide advanced team and repository management:

# Creating an Organization 1. Click your profile > Settings 2. Select "Organizations" 3. Click "New organization" 4. Choose plan (Free/Team/Enterprise) 5. Configure organization settings Organization Features: ✓ Team-based access control ✓ Multiple repository ownership ✓ Organization-wide settings ✓ Audit logs ✓ Billing management ✓ OAuth app restrictions ✓ Organization Projects ✓ Organization Discussions

Team management best practices:

# Create teams based on function - @org/frontend-team - @org/backend-team - @org/devops-team - @org/security-team # Assign team permissions - Read: View and clone - Triage: Manage issues and PRs - Write: Push and create branches - Maintain: Manage settings (no destructive actions) - Admin: Full access including deletion # Use team mentions in issues/PRs "@org/frontend-team please review the UI changes" # Set CODEOWNERS by team # CODEOWNERS file *.js @org/frontend-team *.py @org/backend-team *.yml @org/devops-team

GitHub Sponsors

GitHub Sponsors allows maintainers to receive funding for their work:

# Setting up GitHub Sponsors 1. Go to github.com/sponsors 2. Join the waitlist or apply 3. Set up your sponsor profile 4. Configure sponsorship tiers 5. Add funding options to repositories # Add .github/FUNDING.yml github: [username1, username2] patreon: username open_collective: projectname custom: ["https://yourwebsite.com/donate"]

Advanced Repository Features

Additional features that enhance repository functionality:

Repository Templates: - Create reusable repository structures - Include default files and folders - Template repositories for common project types Code Scanning: - Automated security vulnerability detection - CodeQL analysis - Integration with security advisories Dependency Graph: - Visualize project dependencies - Automated dependency updates (Dependabot) - Security vulnerability alerts Repository Insights: - Contributor statistics - Traffic analytics - Commit activity graphs - Code frequency visualization

Practice Exercise:

Explore GitHub Advanced Features:

  1. Create a GitHub Pages site from one of your repositories
  2. Create a public gist with a code snippet and embed it
  3. Enable Discussions on a repository and create categories
  4. Set up a Wiki with at least 3 pages and a sidebar
  5. Create a release with semantic versioning and release notes
  6. Install GitHub CLI and practice 5 different commands
  7. Download GitHub Mobile and review a pull request

Summary

In this lesson, you learned about:

  • GitHub Pages for hosting static websites and documentation
  • GitHub Gists for sharing code snippets and notes
  • GitHub Discussions for community engagement and Q&A
  • GitHub Wikis for comprehensive project documentation
  • Creating releases with semantic versioning and changelogs
  • GitHub CLI for terminal-based GitHub operations
  • GitHub Mobile for managing projects on the go
  • Organization management for team collaboration
  • GitHub Sponsors and additional repository features
Next Up: In the next lesson, we'll explore team collaboration strategies and workflows!