GitHub
This content is for Frontend. Switch to the latest version for up-to-date documentation.
GitHub is a cloud-based platform for hosting Git repositories. It adds collaboration features on top of Git — pull requests, code reviews, issue tracking, project boards, and CI/CD via GitHub Actions.
GitHub is the largest code hosting platform in the world, with over 100 million developers.
GitHub vs Git
Section titled “GitHub vs Git”| Git | GitHub | |
|---|---|---|
| What | Version control tool | Cloud platform for hosting Git repos |
| Runs | Locally on your machine | In the browser / cloud |
| Purpose | Track changes, branch, merge | Collaborate, review, deploy |
| Required? | Yes (core tool) | No (alternatives exist), but widely used |
Getting Started
Section titled “Getting Started”Creating a Repository
Section titled “Creating a Repository”- Click New on GitHub.
- Name it, choose public/private, optionally add a README and
.gitignore. - Clone it locally:
git clone https://github.com/your-username/my-project.gitcd my-projectConnecting a Local Repo to GitHub
Section titled “Connecting a Local Repo to GitHub”If you already have a local Git repo:
git remote add origin https://github.com/your-username/my-project.gitgit branch -M maingit push -u origin mainPull Requests (PRs)
Section titled “Pull Requests (PRs)”A Pull Request is GitHub’s mechanism for proposing changes and requesting code review before merging.
The PR Workflow
Section titled “The PR Workflow”- Create a branch and make your changes.
- Push the branch to GitHub.
- Open a Pull Request from the GitHub UI.
- Teammates review the code — leave comments, request changes, or approve.
- Once approved, merge the PR into
main. - Delete the feature branch (cleanup).
# Push your branchgit push origin feature/user-auth
# Then open a PR on GitHub via the web UIWriting Good PRs
Section titled “Writing Good PRs”- Title: Short and descriptive (e.g., “Add user authentication flow”).
- Description: Explain what changed, why, and how to test it.
- Small PRs: Smaller changes are easier and faster to review.
- Screenshots: Include UI screenshots for frontend changes.
Code Reviews
Section titled “Code Reviews”Code reviews are one of the most valuable practices in software development:
- Catch bugs before they reach production.
- Share knowledge across the team.
- Improve code quality through discussion.
- Onboard new members by exposing them to different parts of the codebase.
Review Etiquette
Section titled “Review Etiquette”- Be respectful and constructive.
- Explain why something should change, not just what.
- Approve when it’s good enough — perfection is the enemy of progress.
Issues
Section titled “Issues”Issues are GitHub’s way to track bugs, feature requests, tasks, and discussions.
- Use labels to categorize (e.g.,
bug,enhancement,documentation). - Use milestones to group issues into releases or sprints.
- Reference issues in commits:
git commit -m "Fix login redirect (closes #42)"— this automatically closes issue #42 when merged.
GitHub Actions (CI/CD)
Section titled “GitHub Actions (CI/CD)”GitHub Actions lets you automate workflows directly in your repository. Common uses: run tests on every push, deploy on merge to main, lint code on PRs.
Example: Run Tests on Every Push
Section titled “Example: Run Tests on Every Push”name: CI
on: push: branches: [main] pull_request: branches: [main]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - run: npm install - run: npm testKey Concepts
Section titled “Key Concepts”| Term | Meaning |
|---|---|
| Workflow | A YAML file defining automated tasks (lives in .github/workflows/). |
Trigger (on) | The event that starts the workflow (push, PR, schedule, manual). |
| Job | A set of steps that run on the same machine. |
| Step | A single task — run a command or use a pre-built action. |
| Action | A reusable unit of work (e.g., actions/checkout@v4). |
GitHub Pages
Section titled “GitHub Pages”GitHub Pages is free static site hosting directly from a GitHub repository. Great for documentation, portfolios, and project landing pages.
- Enable in Settings → Pages.
- Deploy from
mainbranch, a/docsfolder, or a GitHub Actions workflow.
Other Platforms
Section titled “Other Platforms”GitHub is the most popular, but alternatives exist:
| Platform | Notes |
|---|---|
| GitLab | Git hosting with built-in CI/CD. Self-hosting option. Popular in enterprise. |
| Bitbucket | Git hosting by Atlassian. Integrates tightly with Jira. |
| Gitea | Lightweight, self-hosted Git platform. |